Skip to content

Commit

Permalink
Merge pull request #277 from GSA/fix-collection-with-missing-parent
Browse files Browse the repository at this point in the history
fix UI issue when a collection dataset with missing parent
  • Loading branch information
Jin-Sun-tts authored Jan 24, 2024
2 parents 2258fa6 + 10f58f2 commit eabc515
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 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 a deleted 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 %}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="ckanext-geodatagov",
version="0.2.7",
version="0.2.8",
description="",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit eabc515

Please sign in to comment.