Skip to content

Commit 8a2b51e

Browse files
committed
Merge pull request #22 from conwetlab/develop
Version 0.3.1
2 parents f09b87b + 4817db4 commit 8a2b51e

File tree

12 files changed

+85
-45
lines changed

12 files changed

+85
-45
lines changed

MANIFEST.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
recursive-include ckanext/datarequests/templates *
22
recursive-include ckanext/datarequests/public *
3-
recursive-include ckanext/datarequests/fanstatic *
3+
recursive-include ckanext/datarequests/fanstatic *
4+
recursive-include ckanext/datarequests/i18n *

ckanext/datarequests/controllers/ui_controller.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def delete(self, id):
258258
try:
259259
tk.check_access(constants.DATAREQUEST_DELETE, context, data_dict)
260260
datarequest = tk.get_action(constants.DATAREQUEST_DELETE)(context, data_dict)
261-
helpers.flash_notice(tk._('Your Data Request %s has been deleted') % datarequest.get('title', ''))
261+
helpers.flash_notice(tk._('Data Request %s has been deleted') % datarequest.get('title', ''))
262262
base.redirect(helpers.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='index'))
263263
except tk.ObjectNotFound as e:
264264
log.warn(e)
@@ -363,9 +363,9 @@ def comment(self, id):
363363
updated_comment = tk.get_action(action)(context, comment_data_dict)
364364

365365
if not comment_id:
366-
flash_message = tk._('Your comment has been published')
366+
flash_message = tk._('Comment has been published')
367367
else:
368-
flash_message = tk._('Your comment has been updated')
368+
flash_message = tk._('Comment has been updated')
369369

370370
helpers.flash_notice(flash_message)
371371

@@ -411,7 +411,7 @@ def delete_comment(self, datarequest_id, comment_id):
411411
data_dict = {'id': comment_id}
412412
tk.check_access(constants.DATAREQUEST_COMMENT_DELETE, context, data_dict)
413413
tk.get_action(constants.DATAREQUEST_COMMENT_DELETE)(context, data_dict)
414-
helpers.flash_notice(tk._('Your comment has been deleted'))
414+
helpers.flash_notice(tk._('Comment has been deleted'))
415415
base.redirect(helpers.url_for(controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI',
416416
action='comment', id=datarequest_id))
417417
except tk.ObjectNotFound as e:

ckanext/datarequests/i18n/ckanext-datarequests.pot

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#, fuzzy
88
msgid ""
99
msgstr ""
10-
"Project-Id-Version: ckanext-datarequests 0.3.0\n"
10+
"Project-Id-Version: ckanext-datarequests 0.3.1\n"
1111
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
12-
"POT-Creation-Date: 2016-04-25 10:19+0200\n"
12+
"POT-Creation-Date: 2016-04-28 11:43+0200\n"
1313
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1414
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1515
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -168,7 +168,7 @@ msgstr ""
168168

169169
#: ckanext/datarequests/controllers/ui_controller.py:261
170170
#, python-format
171-
msgid "Your Data Request %s has been deleted"
171+
msgid "Data Request %s has been deleted"
172172
msgstr ""
173173

174174
#: ckanext/datarequests/controllers/ui_controller.py:268
@@ -186,11 +186,11 @@ msgid "You are not authorized to close the Data Request %s"
186186
msgstr ""
187187

188188
#: ckanext/datarequests/controllers/ui_controller.py:366
189-
msgid "Your comment has been published"
189+
msgid "Comment has been published"
190190
msgstr ""
191191

192192
#: ckanext/datarequests/controllers/ui_controller.py:368
193-
msgid "Your comment has been updated"
193+
msgid "Comment has been updated"
194194
msgstr ""
195195

196196
#: ckanext/datarequests/controllers/ui_controller.py:374
@@ -204,7 +204,7 @@ msgid "You are not authorized to list the comments of the Data Request %s"
204204
msgstr ""
205205

206206
#: ckanext/datarequests/controllers/ui_controller.py:414
207-
msgid "Your comment has been deleted"
207+
msgid "Comment has been deleted"
208208
msgstr ""
209209

210210
#: ckanext/datarequests/controllers/ui_controller.py:419
@@ -407,7 +407,7 @@ msgid "No Data Requests found"
407407
msgstr ""
408408

409409
#: ckanext/datarequests/templates/datarequests/snippets/datarequest_list.html:14
410-
msgid "There are currently no Data Requests for this site"
410+
msgid "No Data Requests found with the given criteria"
411411
msgstr ""
412412

413413
#: ckanext/datarequests/templates/datarequests/snippets/datarequest_list.html:16
@@ -469,6 +469,6 @@ msgstr ""
469469

470470
#: ckanext/datarequests/tests/test_ui_controller.py:672
471471
#, python-format
472-
msgid "Data Request %s deleted correctly"
472+
msgid "Your Data Request %s has been deleted"
473473
msgstr ""
474474

Binary file not shown.

ckanext/datarequests/i18n/es/LC_MESSAGES/ckanext-datarequests.po

+11-17
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ msgid ""
99
msgstr ""
1010
"Project-Id-Version: ckanext-datarequests 0.3.0\n"
1111
"Report-Msgid-Bugs-To: [email protected]\n"
12-
"POT-Creation-Date: 2016-04-25 10:19+0200\n"
12+
"POT-Creation-Date: 2016-04-28 11:43+0200\n"
1313
"PO-Revision-Date: 2016-04-19 11:43+0200\n"
1414
"Last-Translator: Aitor Magán <[email protected]>\n"
1515
"Language-Team: es <[email protected]>\n"
@@ -142,8 +142,8 @@ msgstr "No estás autorizado a actualizar la Solicitud de Datos %s"
142142

143143
#: ckanext/datarequests/controllers/ui_controller.py:261
144144
#, python-format
145-
msgid "Your Data Request %s has been deleted"
146-
msgstr "Tu Solicitud de Datos %s ha sido borrada"
145+
msgid "Data Request %s has been deleted"
146+
msgstr "La Solicitud de Datos %s ha sido borrada"
147147

148148
#: ckanext/datarequests/controllers/ui_controller.py:268
149149
#, python-format
@@ -160,12 +160,12 @@ msgid "You are not authorized to close the Data Request %s"
160160
msgstr "No estás autorizado a cerrar la Solicitud de Datos %s"
161161

162162
#: ckanext/datarequests/controllers/ui_controller.py:366
163-
msgid "Your comment has been published"
164-
msgstr "Tu comentario ha sido publicado"
163+
msgid "Comment has been published"
164+
msgstr "El comentario ha sido publicado"
165165

166166
#: ckanext/datarequests/controllers/ui_controller.py:368
167-
msgid "Your comment has been updated"
168-
msgstr "Tu comentario ha sido actualizado"
167+
msgid "Comment has been updated"
168+
msgstr "El comentario ha sido actualizado"
169169

170170
#: ckanext/datarequests/controllers/ui_controller.py:374
171171
#, python-format
@@ -178,8 +178,8 @@ msgid "You are not authorized to list the comments of the Data Request %s"
178178
msgstr "No estás autorizado a ver los comentarios de la Solicitud de Datos %s"
179179

180180
#: ckanext/datarequests/controllers/ui_controller.py:414
181-
msgid "Your comment has been deleted"
182-
msgstr "Tu comentario ha sido borrado"
181+
msgid "Comment has been deleted"
182+
msgstr "El comentario ha sido borrado"
183183

184184
#: ckanext/datarequests/controllers/ui_controller.py:419
185185
#, python-format
@@ -364,8 +364,8 @@ msgid "No Data Requests found"
364364
msgstr "No hay Solicitudes de Datos"
365365

366366
#: ckanext/datarequests/templates/datarequests/snippets/datarequest_list.html:14
367-
msgid "There are currently no Data Requests for this site"
368-
msgstr "Actualmente no hay Solicitudes de Datos para este sitio"
367+
msgid "No Data Requests found with the given criteria"
368+
msgstr "No se han encontrado Solicitudes de Datos para los criterios dados"
369369

370370
#: ckanext/datarequests/templates/datarequests/snippets/datarequest_list.html:16
371371
msgid "How about creating one?"
@@ -374,9 +374,3 @@ msgstr "¿Quieres crear una?"
374374
#: ckanext/datarequests/templates/datarequests/snippets/edit_datarequest_form.html:4
375375
msgid "Update Data Request"
376376
msgstr "Actualizar Solicitud de Datos"
377-
378-
#: ckanext/datarequests/tests/test_ui_controller.py:672
379-
#, python-format
380-
msgid "Data Request %s deleted correctly"
381-
msgstr "Solicitud de Datos %s borrada correctamente"
382-

ckanext/datarequests/plugin.py

+46-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import os
2727
import sys
2828

29-
from ckan.lib.plugins import DefaultTranslation
3029
from functools import partial
3130
from pylons import config
3231

@@ -37,14 +36,19 @@ def get_config_bool_value(config_name, default_value=False):
3736
return value
3837

3938

40-
class DataRequestsPlugin(p.SingletonPlugin, DefaultTranslation):
39+
class DataRequestsPlugin(p.SingletonPlugin):
4140

4241
p.implements(p.IActions)
4342
p.implements(p.IAuthFunctions)
4443
p.implements(p.IConfigurer)
4544
p.implements(p.IRoutes, inherit=True)
4645
p.implements(p.ITemplateHelpers)
47-
p.implements(p.ITranslation)
46+
47+
# ITranslation only available in 2.5+
48+
try:
49+
p.implements(p.ITranslation)
50+
except AttributeError:
51+
pass
4852

4953
def __init__(self, name=None):
5054
self.comments_enabled = get_config_bool_value('ckan.datarequests.comments', True)
@@ -184,3 +188,42 @@ def get_helpers(self):
184188
'get_open_datarequests_number': helpers.get_open_datarequests_number,
185189
'get_open_datarequests_badge': partial(helpers.get_open_datarequests_badge, self._show_datarequests_badge)
186190
}
191+
192+
######################################################################
193+
########################### ITRANSLATION #############################
194+
######################################################################
195+
196+
# The following methods are copied from ckan.lib.plugins.DefaultTranslation
197+
# and have been modified to fix a bug in CKAN 2.5.1 that prevents CKAN from
198+
# starting. In addition by copying these methods, it is ensured that Data
199+
# Requests can be used even if Itranslation isn't available (less than 2.5)
200+
201+
def i18n_directory(self):
202+
'''Change the directory of the *.mo translation files
203+
The default implementation assumes the plugin is
204+
ckanext/myplugin/plugin.py and the translations are stored in
205+
i18n/
206+
'''
207+
# assume plugin is called ckanext.<myplugin>.<...>.PluginClass
208+
extension_module_name = '.'.join(self.__module__.split('.')[:3])
209+
module = sys.modules[extension_module_name]
210+
return os.path.join(os.path.dirname(module.__file__), 'i18n')
211+
212+
def i18n_locales(self):
213+
'''Change the list of locales that this plugin handles
214+
By default the will assume any directory in subdirectory in the
215+
directory defined by self.directory() is a locale handled by this
216+
plugin
217+
'''
218+
directory = self.i18n_directory()
219+
return [ d for
220+
d in os.listdir(directory)
221+
if os.path.isdir(os.path.join(directory, d))
222+
]
223+
224+
def i18n_domain(self):
225+
'''Change the gettext domain handled by this plugin
226+
This implementation assumes the gettext domain is
227+
ckanext-{extension name}, hence your pot, po and mo files should be
228+
named ckanext-{extension name}.mo'''
229+
return 'ckanext-{name}'.format(name=self.name)

ckanext/datarequests/templates/datarequests/comment.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010

1111
{% snippet "datarequests/snippets/comments.html", comments=c.comments, datarequest=c.datarequest, errors=c.errors, errors_summary=c.errors_summary, updated_comment=c.updated_comment %}
1212

13-
<div class="comment-new">
14-
{% if h.check_access('datarequest_comment', {'id':c.datarequest.id }) %}
13+
{% if h.check_access('datarequest_comment', {'id':c.datarequest.id }) %}
14+
<div class="comment-new">
15+
1516
{% set create_comment_error = c.updated_comment is defined and c.updated_comment.id == '' %}
1617

1718
{% if create_comment_error %}
1819
<a name="comment_focus"></a>
1920
{% endif %}
2021

2122
{% snippet "datarequests/snippets/comment_form.html", datarequest=c.datarequest, errors=c.errors, errors_summary=c.errors_summary, offering=c.offering, initial_text=c.updated_comment.comment if create_comment_error, focus=create_comment_error, current_user=c.userobj %}
22-
{% endif %}
23-
</div>
23+
</div>
24+
{% endif %}
2425

2526
{% endblock %}

ckanext/datarequests/templates/datarequests/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</div>
1111
{% endif %}
1212
{% snippet 'snippets/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 %}
13+
<br />
1314
{{ h.snippet('datarequests/snippets/datarequest_list.html', datarequest_count=c.datarequest_count, datarequests=c.datarequests, page=c.page, q=c.q)}}
1415
{% endblock %}
1516
</div>

ckanext/datarequests/templates/datarequests/snippets/datarequest_list.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% set title= _('No Data Requests found') if datarequest_count == 0 else '%s datarequest found' % datarequest_count %}
22

3-
<!--<h2>{{ title }}</h2>-->
3+
<!--<h2>{{ title }}</h2>!-->
44

55
{% block datarequest_search_results_list %}
66
{% if datarequests %}
@@ -11,9 +11,9 @@
1111
</ul>
1212
{% else %}
1313
<p class="empty">
14-
{{ _('There are currently no Data Requests for this site') }}.
14+
{{ _('No Data Requests found with the given criteria') }}.
1515
{% if h.check_access('datarequest_create') %}
16-
{% link_for _('How about creating one?'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='new' %}</a>.
16+
{% link_for _('How about creating one?'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='new' %}</a>
1717
{% endif %}
1818
</p>
1919
{% endif %}

ckanext/datarequests/tests/test_selenium.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,11 @@ def test_delete_datarequest(self):
420420
self.delete_datarequest(datarequest_id)
421421

422422
# Check that there are not more data requests in the system
423-
self.assertTrue("There are currently no Data Requests for this site."
423+
self.assertTrue("No Data Requests found with the given criteria."
424424
in self.driver.find_element_by_css_selector("p.empty").text)
425425

426426
# Check flash message
427-
self.assertTrue("Your Data Request " + datarequest_title + " has been deleted"
427+
self.assertTrue("Data Request " + datarequest_title + " has been deleted"
428428
in self.driver.find_element_by_xpath("//div[@id='content']/div/div").text)
429429

430430
def test_close_datarequest(self):
@@ -644,7 +644,7 @@ def test_delete_comment(self):
644644
# Check that the comment has been deleted
645645
self.assertEqual("This data request has not been commented yet",
646646
self.driver.find_element_by_css_selector("p.empty").text)
647-
self.assertTrue("Your comment has been deleted" in self.driver.find_element_by_xpath(
647+
self.assertTrue("Comment has been deleted" in self.driver.find_element_by_xpath(
648648
"//div[@id='content']/div/div").text)
649649

650650
def test_new_comments_always_visible(self):

ckanext/datarequests/tests/test_ui_controller.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ def test_delete(self):
669669
controller.tk.check_access.assert_called_once_with(constants.DATAREQUEST_DELETE, self.expected_context, expected_data_dict)
670670
datarequest_delete.assert_called_once_with(self.expected_context, expected_data_dict)
671671
controller.helpers.flash_notice.assert_called_once_with(controller.tk._(
672-
'Your Data Request %s has been deleted' % datarequest.get('title')))
672+
'Data Request %s has been deleted' % datarequest.get('title')))
673673

674674
# Redirection
675675
controller.helpers.url_for.assert_called_once_with(

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from setuptools import setup, find_packages
2121
import sys, os
2222

23-
version = '0.3.0'
23+
version = '0.3.1'
2424

2525
setup(
2626
name='ckanext-datarequests',

0 commit comments

Comments
 (0)