Skip to content

Commit

Permalink
Merge branch 'develop' for relase 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitor Magán García committed Sep 18, 2017
2 parents 39bfe7f + 53fa009 commit f1ae0b4
Show file tree
Hide file tree
Showing 18 changed files with 128 additions and 145 deletions.
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
sudo: required
language: python
python:
- "2.7"
env:
- CKANVERSION=2.5.6 POSTGISVERSION=2
- CKANVERSION=2.6.3 POSTGISVERSION=2
- CKANVERSION=2.7.0 POSTGISVERSION=2
services:
- redis-server
- postgresql
addons:
firefox: "46.0"
install:
- bash bin/travis-build.bash
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
script:
- sh bin/travis-run.sh
branches:
only:
- develop
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CKAN Data Requests [![Build Status](https://build.conwet.fi.upm.es/jenkins/buildStatus/icon?job=ckan_datarequests)](https://build.conwet.fi.upm.es/jenkins/job/ckan_datarequests/)
# CKAN Data Requests [![Build Status](https://travis-ci.org/conwetlab/ckanext-datarequests.svg?branch=develop)](https://travis-ci.org/conwetlab/ckanext-datarequests)

CKAN extension that allows users to ask for datasets that are not already published in the CKAN instance. In this way we can set up a Data Market, not only with data supplies but also with data demands.

Expand Down Expand Up @@ -225,6 +225,11 @@ python setup.py nosetests
## Changelog
### v0.4.0
* New: Move CI to Travis
* New: Compatibility with CKAN 2.7 (controller adapted by @owl17)
### v0.3.3
* New: German Translation (thanks to @kvlahrosch)
Expand Down
108 changes: 0 additions & 108 deletions bin/setup_and_test.sh

This file was deleted.

43 changes: 43 additions & 0 deletions bin/travis-build.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -e

echo "This is travis-build.bash..."

echo "Installing the packages that CKAN requires..."
sudo apt-get update -qq
sudo apt-get install solr-jetty

echo "Installing CKAN and its Python dependencies..."
git clone https://github.com/ckan/ckan
cd ckan
git checkout ckan-$CKANVERSION
python setup.py develop
pip install -r requirements.txt --allow-all-external
pip install -r dev-requirements.txt --allow-all-external
cd -

echo "Setting up Solr..."
# solr is multicore for tests on ckan master now, but it's easier to run tests
# on Travis single-core still.
# see https://github.com/ckan/ckan/issues/2972
sed -i -e 's/solr_url.*/solr_url = http:\/\/127.0.0.1:8983\/solr/' ckan/test-core.ini
printf "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
sudo cp ckan/ckan/config/solr/schema.xml /etc/solr/conf/schema.xml
sudo service jetty restart

echo "Creating the PostgreSQL user and database..."
sudo -u postgres psql -c "CREATE USER ckan_default WITH PASSWORD 'pass';"
sudo -u postgres psql -c "CREATE USER datastore_default WITH PASSWORD 'pass';"
sudo -u postgres psql -c "CREATE DATABASE ckan_test WITH OWNER ckan_default;"
sudo -u postgres psql -c "CREATE DATABASE datastore_test WITH OWNER ckan_default;"


echo "Initialising the database..."
cd ckan
paster db init -c test-core.ini
cd -

echo "Installing ckanext-datarequests and its requirements..."
python setup.py develop

echo "travis-build.bash is done."
3 changes: 3 additions & 0 deletions bin/travis-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh -e

python setup.py nosetests
11 changes: 4 additions & 7 deletions ckanext/datarequests/controllers/ui_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ def _process_post(self, action, context):

try:
result = tk.get_action(action)(context, data_dict)
base.redirect(helpers.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI',
action='show', id=result['id']))
tk.redirect_to(helpers.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='show', id=result['id']))

except tk.ValidationError as e:
log.warn(e)
Expand Down Expand Up @@ -259,7 +258,7 @@ def delete(self, id):
tk.check_access(constants.DATAREQUEST_DELETE, context, data_dict)
datarequest = tk.get_action(constants.DATAREQUEST_DELETE)(context, data_dict)
helpers.flash_notice(tk._('Data Request %s has been deleted') % datarequest.get('title', ''))
base.redirect(helpers.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='index'))
tk.redirect_to(helpers.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='index'))
except tk.ObjectNotFound as e:
log.warn(e)
tk.abort(404, tk._('Data Request %s not found') % id)
Expand Down Expand Up @@ -320,8 +319,7 @@ def _return_page(errors={}, errors_summary={}):
data_dict['id'] = id

tk.get_action(constants.DATAREQUEST_CLOSE)(context, data_dict)
base.redirect(helpers.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI',
action='show', id=data_dict['id']))
tk.redirect_to(helpers.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='show', id=data_dict['id']))
else: # GET
return _return_page()

Expand Down Expand Up @@ -412,8 +410,7 @@ def delete_comment(self, datarequest_id, comment_id):
tk.check_access(constants.DATAREQUEST_COMMENT_DELETE, context, data_dict)
tk.get_action(constants.DATAREQUEST_COMMENT_DELETE)(context, data_dict)
helpers.flash_notice(tk._('Comment has been deleted'))
base.redirect(helpers.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI',
action='comment', id=datarequest_id))
tk.redirect_to(helpers.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='comment', id=datarequest_id))
except tk.ObjectNotFound as e:
log.warn(e)
tk.abort(404, tk._('Comment %s not found') % comment_id)
Expand Down
23 changes: 19 additions & 4 deletions ckanext/datarequests/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with CKAN Data Requests Extension. If not, see <http://www.gnu.org/licenses/>.

import ckan.lib.helpers as h
import ckan.plugins as p
import ckan.plugins.toolkit as tk
import auth
Expand All @@ -35,6 +36,19 @@ def get_config_bool_value(config_name, default_value=False):
value = value if type(value) == bool else value != 'False'
return value

def is_fontawesome_4():
if hasattr(h, 'ckan_version'):
ckan_version = float(h.ckan_version()[0:3])
return ckan_version >= 2.7
else:
return False

def get_plus_icon():
return 'plus-square' if is_fontawesome_4() else 'plus-sign-alt'

def get_question_icon():
return 'question-circle' if is_fontawesome_4() else 'question-sign'


class DataRequestsPlugin(p.SingletonPlugin):

Expand Down Expand Up @@ -134,7 +148,7 @@ def before_map(self, m):
# Show a Data Request
m.connect('datarequest_show', '/%s/{id}' % constants.DATAREQUESTS_MAIN_PATH,
controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI',
action='show', conditions=dict(method=['GET']), ckan_icon='question-sign')
action='show', conditions=dict(method=['GET']), ckan_icon=get_question_icon())

# Update a Data Request
m.connect('/%s/edit/{id}' % constants.DATAREQUESTS_MAIN_PATH,
Expand All @@ -155,13 +169,13 @@ def before_map(self, m):
m.connect('organization_datarequests', '/organization/%s/{id}' % constants.DATAREQUESTS_MAIN_PATH,
controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI',
action='organization_datarequests', conditions=dict(method=['GET']),
ckan_icon='question-sign')
ckan_icon=get_question_icon())

# Data Request that belongs to an user
m.connect('user_datarequests', '/user/%s/{id}' % constants.DATAREQUESTS_MAIN_PATH,
controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI',
action='user_datarequests', conditions=dict(method=['GET']),
ckan_icon='question-sign')
ckan_icon=get_question_icon())

if self.comments_enabled:
# Comment, update and view comments (of) a Data Request
Expand All @@ -186,7 +200,8 @@ def get_helpers(self):
'get_comments_number': helpers.get_comments_number,
'get_comments_badge': helpers.get_comments_badge,
'get_open_datarequests_number': helpers.get_open_datarequests_number,
'get_open_datarequests_badge': partial(helpers.get_open_datarequests_badge, self._show_datarequests_badge)
'get_open_datarequests_badge': partial(helpers.get_open_datarequests_badge, self._show_datarequests_badge),
'get_plus_icon': get_plus_icon
}

######################################################################
Expand Down
2 changes: 1 addition & 1 deletion ckanext/datarequests/templates/datarequests/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{% block secondary_content %}

<section class="module module-narrow module-shallow">
<h2 class="module-heading"><i class="icon-info-sign"></i>{% trans %}Data Request{% endtrans %}</h2>
<h2 class="module-heading"><i class="icon-info-sign fa fa-info-circle"></i>{% trans %}Data Request{% endtrans %}</h2>
<div class="module-content">
<p>
{% trans %}Data Requests allow users to ask for data that is not published in the platform yet. If you want some specific data and you are not able to find it among all the published datasets, you can create a new data request specifying the data than you want to get.{% endtrans %}
Expand Down
2 changes: 1 addition & 1 deletion ckanext/datarequests/templates/datarequests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% block page_primary_action %}
{% if h.check_access('datarequest_create') %}
<div class="page_primary_action">
{% link_for _('Add Data Request'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='new', class_='btn btn-primary', icon='plus-sign-alt' %}
{% link_for _('Add Data Request'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='new', class_='btn btn-primary', icon=h.get_plus_icon() %}
</div>
{% endif %}
{% snippet 'snippets/custom_search_form.html', query=c.q, fields=(('organization', c.organization), ('state', c.state)), sorting=c.filters, sorting_selected=c.sort, placeholder=_('Search Data Requests...'), no_bottom_border=true, count=c.datarequest_count, no_title=True %}
Expand Down
4 changes: 2 additions & 2 deletions ckanext/datarequests/templates/datarequests/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
{% block primary_content_inner %}
{% if c.datarequest.closed %}
<span class="uppercase label label-closed pull-right">
<i class="icon-lock"></i>
<i class="icon-lock fa fa-lock"></i>
{{ _('Closed') }}
</span>
{% else %}
<span class="uppercase label label-open pull-right">
<i class="icon-unlock"></i>
<i class="icon-unlock fa fa-unlock"></i>
{{ _('Open') }}
</span>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
{% if h.check_access('datarequest_comment_delete', {'id':comment.id }) %}
<div class="comment-action">
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this comment?')}) %}
<a class="subtle-btn" id="delete-comment-{{ comment.id }}" href="{% url_for controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='delete_comment', datarequest_id=datarequest.id, comment_id=comment.id %}" data-module="confirm-action" data-module-i18n="{{ locale }}"><i class="icon-remove"></i></a>
<a class="subtle-btn" id="delete-comment-{{ comment.id }}" href="{% url_for controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='delete_comment', datarequest_id=datarequest.id, comment_id=comment.id %}" data-module="confirm-action" data-module-i18n="{{ locale }}"><i class="icon-remove fa fa-times"></i></a>
</div>
{% endif %}
{% if can_update %}
<div class="comment-action" id="edit-button">
<button class="subtle-btn" id="update-comment-{{ comment.id }}" href=""><i class="icon-pencil"></i></button>
<button class="subtle-btn" id="update-comment-{{ comment.id }}" href=""><i class="icon-pencil fa fa-pencil"></i></button>
</div>
{% endif %}
<div class="comment-header-text">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<h3 class="dataset-heading">
{% if datarequest.get('closed', False) %}
<span class="uppercase label label-closed">
<i class="icon-lock"></i> {% trans %}Closed{% endtrans %}
<i class="icon-lock fa fa-lock"></i> {% trans %}Closed{% endtrans %}
</span>
{% else %}
<span class="uppercase label label-open">
<i class="icon-unlock"></i> {% trans %}Open{% endtrans %}
<i class="icon-unlock fa fa-unlock"></i> {% trans %}Open{% endtrans %}
</span>
{% endif %}
{{ h.link_to(h.truncate(title, truncate_title), h.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='show', id=datarequest.get('id', ''))) }}
Expand All @@ -23,7 +23,7 @@ <h3 class="dataset-heading">
{% endif %}
<div class="datarequest-properties">
{% if h.show_comments_tab() %}
<a href="{{ h.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='comment', id=datarequest.get('id','')) }}" class="label"><i class="icon-comment"></i> {{ h.get_comments_number(datarequest.get('id', '')) }}</span></a>
<a href="{{ h.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='comment', id=datarequest.get('id','')) }}" class="label"><i class="icon-comment fa fa-comment"></i> {{ h.get_comments_number(datarequest.get('id', '')) }}</span></a>
{% endif %}
<div class="divider"/>
<span class="date-datarequests">{{ h.time_ago_from_timestamp(datarequest.open_time) }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% block page_primary_action %}
{% if h.check_access('datarequest_create') %}
<div class="page_primary_action">
{% link_for _('Add Data Request'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='new', organization=c.group_dict.id, class_='btn btn-primary', icon='plus-sign-alt' %}
{% link_for _('Add Data Request'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='new', organization=c.group_dict.id, class_='btn btn-primary', icon=h.get_plus_icon() %}
</div>
{% endif %}
{% snippet 'snippets/custom_search_form.html', query=c.q, fields=(('state', c.state),), sorting=c.filters, sorting_selected=c.sort, placeholder=_('Search Data Requests...'), no_bottom_border=true, count=c.datarequest_count, no_title=True %}
Expand Down
Loading

0 comments on commit f1ae0b4

Please sign in to comment.