diff --git a/ckanext/geodatagov/helpers.py b/ckanext/geodatagov/helpers.py index 1a1892d0..5ab56f81 100644 --- a/ckanext/geodatagov/helpers.py +++ b/ckanext/geodatagov/helpers.py @@ -3,6 +3,7 @@ from ckan import plugins as p from ckanext.harvest.model import HarvestSource +from ckan.logic import NotFound, NotAuthorized log = logging.getLogger(__name__) @@ -59,8 +60,11 @@ def get_harvest_source_config(harvester_id): def get_collection_package(collection_package_id): - package = p.toolkit.get_action('package_show')({}, {'id': collection_package_id}) - return package + try: + package = p.toolkit.get_action('package_show')({}, {'id': collection_package_id}) + return package + except (NotFound, NotAuthorized): + pass def string(value): diff --git a/ckanext/geodatagov/templates/package/read.html b/ckanext/geodatagov/templates/package/read.html index 3ebea9bb..c606fadb 100644 --- a/ckanext/geodatagov/templates/package/read.html +++ b/ckanext/geodatagov/templates/package/read.html @@ -14,10 +14,15 @@

{{ _('Collection') }}

{% set collection_package = h.get_collection_package(collection_package_id) %}

{{ _('Collection') }}

-

{{ _('This dataset is part of the following collection:') }}

- + {% if collection_package %} +

{{ _('This dataset is part of the following collection:') }}

+ + {% else %} +

{{ _('This dataset is part of the a collection.') }}

+

{{ _('Search other datasets within the same collection') }}

+ {% endif %}
{% endif %} {% endblock %}