Skip to content

Commit

Permalink
added exception for parent dataset absent in collection
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin-Sun-tts committed Jan 24, 2024
1 parent 2258fa6 commit 7820d1d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 6 additions & 2 deletions ckanext/geodatagov/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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):
Expand Down
13 changes: 9 additions & 4 deletions ckanext/geodatagov/templates/package/read.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ <h3>{{ _('Collection') }}</h3>
{% set collection_package = h.get_collection_package(collection_package_id) %}
<section class="module-content">
<h3>{{ _('Collection') }}</h3>
<p>{{ _('This dataset is part of the following collection:') }}</p>
<ul class="dataset-list unstyled">
{% snippet "snippets/package_item.html", package=collection_package, truncate=75 %}
</ul>
{% if collection_package %}
<p>{{ _('This dataset is part of the following collection:') }}</p>
<ul class="dataset-list unstyled">
{% snippet "snippets/package_item.html", package=collection_package, truncate=75 %}
</ul>
{% else %}
<p>{{ _('This dataset is part of the a collection.') }}</p>
<p><a href="{{ h.url_for('search', collection_package_id=collection_package_id) }}" class="btn-collection">{{ _('Search other datasets within the same collection') }}</a></p>
{% endif %}
</section>
{% endif %}
{% endblock %}

0 comments on commit 7820d1d

Please sign in to comment.