Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix UI issue when a collection dataset with missing parent #277

Merged
merged 4 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 %}
Jin-Sun-tts marked this conversation as resolved.
Show resolved Hide resolved
<p>{{ _('This dataset is part of the a collection.') }}</p>
FuhuXia marked this conversation as resolved.
Show resolved Hide resolved
<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