{% endblock %} - -{% block main_content %} -
-
- {% block form %} -

{{ _('Are you sure you want to delete related item - {name}?').format(name=c.related_dict.title) }}

-

-
- - - -

- {% endblock %} -
-
-{% endblock %} diff --git a/ckan/templates/related/dashboard.html b/ckan/templates/related/dashboard.html deleted file mode 100644 index 841abe99d8b..00000000000 --- a/ckan/templates/related/dashboard.html +++ /dev/null @@ -1,94 +0,0 @@ -{% extends "page.html" %} - -{% set page = c.page %} -{% set item_count = c.page.item_count %} - -{% block subtitle %}{{ _('Apps & Ideas') }}{% endblock %} - -{% block breadcrumb_content %} -
  • {{ _('Apps & Ideas') }}
  • -{% endblock %} - -{% block primary_content %} -
    -
    -

    - {% block page_heading %}{{ _('Apps & Ideas') }}{% endblock %} -

    - - {% block related_items %} - {% if item_count %} - {% trans first=page.first_item, last=page.last_item, item_count=item_count %} -

    Showing items {{ first }} - {{ last }} of {{ item_count }} related items found

    - {% endtrans %} - {% elif c.filters.type %} - {% trans item_count=item_count %} -

    {{ item_count }} related items found

    - {% endtrans %} - {% else %} -

    {{ _('There have been no apps submitted yet.') }} - {% endif %} - {% endblock %} - - {% block related_list %} - {% if page.items %} - {% snippet "related/snippets/related_list.html", related_items=page.items %} - {% endif %} - {% endblock %} -

    - - {% block page_pagination %} - {{ page.pager() }} - {% endblock %} -
    -{% endblock %} - -{% block secondary_content %} -
    -

    {{ _('What are applications?') }}

    -
    - {% trans %} - These are applications built with the datasets as well as ideas for - things that could be done with them. - {% endtrans %} -
    -
    - -
    -

    {{ _('Filter Results') }}

    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    -{% endblock %} diff --git a/ckan/templates/related/edit.html b/ckan/templates/related/edit.html deleted file mode 100644 index 26c1e49b701..00000000000 --- a/ckan/templates/related/edit.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "related/base_form_page.html" %} - -{% block subtitle %}{{ _('Edit related item') }}{% endblock %} - -{# TODO: pass the same context in here so we can create links #} -{% block breadcrumb_item %}{{ h.nav_link(_('Edit Related'), controller='related', action='edit', id=c.id, related_id="") }}{% endblock %} - -{% block page_heading %}{{ _('Edit Related Item') }}{% endblock %} diff --git a/ckan/templates/related/edit_form.html b/ckan/templates/related/edit_form.html deleted file mode 100644 index 92cb16696e8..00000000000 --- a/ckan/templates/related/edit_form.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "related/snippets/related_form.html" %} - -{% block button_text %} - {% if data.id %} - {{ _('Update') }} - {% else %} - {{ _('Create') }} - {% endif %} -{% endblock %} - -{% block delete_button %} - {% if data.id %} - {{ super() }} - {% endif %} -{% endblock %} diff --git a/ckan/templates/related/new.html b/ckan/templates/related/new.html deleted file mode 100644 index 7fb3ce90633..00000000000 --- a/ckan/templates/related/new.html +++ /dev/null @@ -1,7 +0,0 @@ -{% extends "related/base_form_page.html" %} - -{% block subtitle %}{{ _('Create a related item') }}{% endblock %} - -{% block breadcrumb_item %}{{ h.nav_link(_('Create Related'), controller='related', action='new', id=c.id) }}{% endblock %} - -{% block page_heading %}{{ _('Create Related Item') }}{% endblock %} diff --git a/ckan/templates/related/snippets/related_form.html b/ckan/templates/related/snippets/related_form.html deleted file mode 100644 index 23ab88c1c84..00000000000 --- a/ckan/templates/related/snippets/related_form.html +++ /dev/null @@ -1,35 +0,0 @@ -{% import 'macros/form.html' as form %} - -
    - {% block error_summary %} - {% if error_summary | count %} -
    -

    {{ _('The form contains invalid entries:') }}

    -
      - {% for key, error in error_summary.items() %} -
    • {{ key }}: {{ error }}
    • - {% endfor %} -
    -
    - {% endif %} - {% endblock %} - - {% block fields %} - {{ form.input('title', label=_('Title'), id='field-title', placeholder=_('My Related Item'), value=data.title, error=errors.title, classes=['control-full']) }} - {{ form.input('url', label=_('URL'), id='field-url', placeholder=_('http://example.com/'), value=data.url, error=errors.url, classes=['control-full']) }} - {{ form.input('image_url', label=_('Image URL'), id='field-image-url', placeholder=_('http://example.com/image.png'), value=data.image_url, error=errors.image_url, classes=['control-full']) }} - {{ form.markdown('description', label=_('Description'), id='field-description', placeholder=_('A little information about the item...'), value=data.description, error=errors.description) }} - {{ form.select('type', label=_('Type'), id='field-types', selected=data.type, options=c.types, error=errors.type) }} - {% endblock %} - -
    - {% block delete_button %} - {% if h.check_access('related_delete', {'id': data.id}) %} - {% set locale = h.dump_json({'content': _('Are you sure you want to delete this related item?')}) %} - {% block delete_button_text %}{{ _('Delete') }}{% endblock %} - {% endif %} - {% endblock %} - {{ h.nav_link(_('Cancel'), controller='related', action='list', id=c.id, class_='btn') }} - -
    - diff --git a/ckan/templates/related/snippets/related_item.html b/ckan/templates/related/snippets/related_item.html deleted file mode 100644 index 2053f7c0406..00000000000 --- a/ckan/templates/related/snippets/related_item.html +++ /dev/null @@ -1,41 +0,0 @@ -{# -Displays a single related item. - -related - The related item dict. -pkg_id - The id of the owner package. If present the edit button will be - displayed. - -Example: - - - -#} -{% set placeholder_map = { -'application': h.url_for_static('/base/images/placeholder-application.png') -} %} -{% set tooltip = _('Go to {related_item_type}').format(related_item_type=related.type|replace('_', ' ')|title) %} - -{% if position is divisibleby 3 %} -
  • -{% endif %} diff --git a/ckan/templates/related/snippets/related_list.html b/ckan/templates/related/snippets/related_list.html deleted file mode 100644 index 7256ba97dc3..00000000000 --- a/ckan/templates/related/snippets/related_list.html +++ /dev/null @@ -1,18 +0,0 @@ -{# -Renders a list of related item elements - -related_items - A list of related items. -pkg_id - A package id for the items used to determine if the edit button - should be displayed. - -Example: - - - {% snippet "related/snippets/related_list.html", related_items=c.pkg.related, pkg_id=c.pkg.name %} - -#} -
      - {% for related in related_items %} - {% snippet "related/snippets/related_item.html", pkg_id=pkg_id, related=related, position=loop.index %} - {% endfor %} -
    diff --git a/ckan/tests/legacy/functional/test_related.py b/ckan/tests/legacy/functional/test_related.py index bb67323520f..aa636a8957d 100644 --- a/ckan/tests/legacy/functional/test_related.py +++ b/ckan/tests/legacy/functional/test_related.py @@ -10,57 +10,6 @@ import ckan.tests.legacy.functional.api.base as apibase -class TestRelatedUI(base.FunctionalTestCase): - @classmethod - def setup_class(self): - model.Session.remove() - tests.CreateTestData.create() - - @classmethod - def teardown_class(self): - model.repo.rebuild_db() - - def test_related_new(self): - offset = h.url_for(controller='related', - action='new', id='warandpeace') - res = self.app.get(offset, status=200, - extra_environ={"REMOTE_USER": "testsysadmin"}) - assert 'URL' in res, "URL missing in response text" - assert 'Title' in res, "Title missing in response text" - - data = { - "title": "testing_create", - "url": u"http://ckan.org/feed/", - } - res = self.app.post(offset, params=data, - status=[200,302], - extra_environ={"REMOTE_USER": "testsysadmin"}) - - def test_related_new_missing(self): - offset = h.url_for(controller='related', - action='new', id='non-existent dataset') - res = self.app.get(offset, status=404, - extra_environ={"REMOTE_USER": "testsysadmin"}) - - def test_related_new_fail(self): - offset = h.url_for(controller='related', - action='new', id='warandpeace') - print '@@@@', offset - res = self.app.get(offset, status=200, - extra_environ={"REMOTE_USER": "testsysadmin"}) - assert 'URL' in res, "URL missing in response text" - assert 'Title' in res, "Title missing in response text" - - data = { - "title": "testing_create", - } - res = self.app.post(offset, params=data, - status=[200,302], - extra_environ={"REMOTE_USER": "testsysadmin"}) - assert 'error' in res, res - - - class TestRelated: @classmethod @@ -357,7 +306,7 @@ def test_update_related_item_check_owner_status(self): } user = model.User.by_name('tester') admin = model.User.by_name('testsysadmin') - + #create related item context = dict(model=model, user=user.name, session=model.Session) data_dict = dict(title="testing_create",description="description", From 91ddda5392ca84311f0822fdf86a9b81a1b19a23 Mon Sep 17 00:00:00 2001 From: Brook Elgie Date: Mon, 7 Sep 2015 15:21:46 +0100 Subject: [PATCH 226/231] [#2619] Close form tag in organization form --- ckan/templates/organization/snippets/organization_form.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckan/templates/organization/snippets/organization_form.html b/ckan/templates/organization/snippets/organization_form.html index 73fa115e2d2..d78a8e959ee 100644 --- a/ckan/templates/organization/snippets/organization_form.html +++ b/ckan/templates/organization/snippets/organization_form.html @@ -1,6 +1,6 @@ {% import 'macros/form.html' as form %} -
    {% block error_summary %} {{ form.errors(error_summary) }} {% endblock %} From 156348c1d11a5ceb556f593d4094074f912842a6 Mon Sep 17 00:00:00 2001 From: David Read Date: Tue, 8 Sep 2015 12:52:58 +0100 Subject: [PATCH 227/231] Stop reraising exceptions caused by notifications. They are secondary errors and should not prevent the change to the dataset occurring. e.g. I am harvesting some data, but because datapusher has an exception, every time the harvester tries to write it has an exception and fails. Admins should look at their logs for these exceptions, and the primary functions should carry on working. --- ckan/model/modification.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ckan/model/modification.py b/ckan/model/modification.py index 585d771198b..6a5213170a2 100644 --- a/ckan/model/modification.py +++ b/ckan/model/modification.py @@ -9,6 +9,7 @@ __all__ = ['DomainObjectModificationExtension'] + class DomainObjectModificationExtension(plugins.SingletonPlugin): """ A domain object level interface to change notifications @@ -30,7 +31,6 @@ def notify_observers(self, func): plugins.IDomainObjectModification): func(observer) - def before_commit(self, session): self.notify_observers(session, self.notify) @@ -60,7 +60,8 @@ def notify_observers(self, session, method): for item in plugins.PluginImplementations(plugins.IResourceUrlChange): item.notify(obj) - changed_pkgs = set(obj for obj in changed if isinstance(obj, _package.Package)) + changed_pkgs = set(obj for obj in changed + if isinstance(obj, _package.Package)) for obj in new | changed | deleted: if not isinstance(obj, _package.Package): @@ -76,7 +77,6 @@ def notify_observers(self, session, method): for obj in changed_pkgs: method(obj, domain_object.DomainObjectOperation.changed) - def notify(self, entity, operation): for observer in plugins.PluginImplementations( plugins.IDomainObjectModification): @@ -84,9 +84,6 @@ def notify(self, entity, operation): observer.notify(entity, operation) except Exception, ex: log.exception(ex) - # We reraise all exceptions so they are obvious there - # is something wrong - raise def notify_after_commit(self, entity, operation): for observer in plugins.PluginImplementations( @@ -95,6 +92,3 @@ def notify_after_commit(self, entity, operation): observer.notify_after_commit(entity, operation) except Exception, ex: log.exception(ex) - # We reraise all exceptions so they are obvious there - # is something wrong - raise From f19705d92da36d77988c7f6ebed6983d3bd0e043 Mon Sep 17 00:00:00 2001 From: Ross Jones Date: Tue, 8 Sep 2015 14:33:42 +0100 Subject: [PATCH 228/231] Make sure that SearchIndexErrors *are* raised CKAN relies on the SearchIndexError being raised in the notify() call of IDomainObjectNotification. It still only logs most Exceptions, but explicitly re-raises SearchIndexErrors as they are fatal to CKAN. --- ckan/model/modification.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ckan/model/modification.py b/ckan/model/modification.py index 6a5213170a2..d8bbcaad665 100644 --- a/ckan/model/modification.py +++ b/ckan/model/modification.py @@ -1,5 +1,7 @@ import logging +from ckan.lib.search import SearchIndexError + import ckan.plugins as plugins import domain_object import package as _package @@ -82,6 +84,9 @@ def notify(self, entity, operation): plugins.IDomainObjectModification): try: observer.notify(entity, operation) + except SearchIndexError, search_error: + log.exception(search_error) + raise search_error except Exception, ex: log.exception(ex) @@ -90,5 +95,8 @@ def notify_after_commit(self, entity, operation): plugins.IDomainObjectModification): try: observer.notify_after_commit(entity, operation) + except SearchIndexError, search_error: + log.exception(search_error) + raise search_error except Exception, ex: log.exception(ex) From 0f516efcf8356c19493ec261b654449c27d2ce88 Mon Sep 17 00:00:00 2001 From: David Read Date: Tue, 8 Sep 2015 14:56:32 +0000 Subject: [PATCH 229/231] Added comment to explain. --- ckan/model/modification.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ckan/model/modification.py b/ckan/model/modification.py index d8bbcaad665..c06c72902b9 100644 --- a/ckan/model/modification.py +++ b/ckan/model/modification.py @@ -86,9 +86,13 @@ def notify(self, entity, operation): observer.notify(entity, operation) except SearchIndexError, search_error: log.exception(search_error) + # Reraise, since it's pretty crucial to ckan if it can't index + # a dataset raise search_error except Exception, ex: log.exception(ex) + # Don't reraise other exceptions since they are generally of + # secondary importance so shouldn't disrupt the commit. def notify_after_commit(self, entity, operation): for observer in plugins.PluginImplementations( @@ -97,6 +101,10 @@ def notify_after_commit(self, entity, operation): observer.notify_after_commit(entity, operation) except SearchIndexError, search_error: log.exception(search_error) + # Reraise, since it's pretty crucial to ckan if it can't index + # a dataset raise search_error except Exception, ex: log.exception(ex) + # Don't reraise other exceptions since they are generally of + # secondary importance so shouldn't disrupt the commit. From f065c5e0b0e3a9c403c42374a479d2a069a60081 Mon Sep 17 00:00:00 2001 From: Brook Elgie Date: Wed, 9 Sep 2015 10:45:59 +0100 Subject: [PATCH 230/231] [#2543] Better test name and comment --- ckan/tests/controllers/test_user.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ckan/tests/controllers/test_user.py b/ckan/tests/controllers/test_user.py index cda6ac6168e..945e8bc6f5a 100644 --- a/ckan/tests/controllers/test_user.py +++ b/ckan/tests/controllers/test_user.py @@ -125,8 +125,12 @@ def test_registered_user_login_bad_password(self): class TestLogout(helpers.FunctionalTestBase): - def test_user_logout(self): - '''_logout url redirects to logged out page.''' + def test_user_logout_url_redirect(self): + '''_logout url redirects to logged out page. + + Note: this doesn't test the actual logout of a logged in user, just + the associated redirect. + ''' app = self._get_test_app() logout_url = url_for(controller='user', action='logout') From 969f7c92fd354d1c3cff765c0f97c93561a46644 Mon Sep 17 00:00:00 2001 From: joetsoi Date: Wed, 9 Sep 2015 15:02:20 +0100 Subject: [PATCH 231/231] pep8 --- ckan/controllers/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckan/controllers/api.py b/ckan/controllers/api.py index 319f395d81a..84f7e0af437 100644 --- a/ckan/controllers/api.py +++ b/ckan/controllers/api.py @@ -509,11 +509,11 @@ def search(self, ver=None, register=None): else: return self._finish_bad_request( _("Missing search term ('since_id=UUID' or " + - " 'since_time=TIMESTAMP')")) + " 'since_time=TIMESTAMP')")) revs = model.Session.query(model.Revision) \ .filter(model.Revision.timestamp > since_time) \ .order_by(model.Revision.timestamp) \ - .limit(50) # reasonable enough for a page + .limit(50) # reasonable enough for a page return self._finish_ok([rev.id for rev in revs]) elif register in ['dataset', 'package', 'resource']: try: