From 7820d1dc0e5474434b68ee33075b254ff1dd0eca Mon Sep 17 00:00:00 2001 From: Jin-Sun-tts Date: Wed, 24 Jan 2024 11:34:11 -0500 Subject: [PATCH 1/4] added exception for parent dataset absent in collection --- ckanext/geodatagov/helpers.py | 8 ++++++-- ckanext/geodatagov/templates/package/read.html | 13 +++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) 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 %} From e2b048d39b3c5c1c58b0d21947450d6638bbeb0f Mon Sep 17 00:00:00 2001 From: Jin-Sun-tts Date: Wed, 24 Jan 2024 11:40:11 -0500 Subject: [PATCH 2/4] bump pypi version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bb59572d..424371b5 100644 --- a/setup.py +++ b/setup.py @@ -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", From de6a89c31eab25dfc7095879a6dc17d577a37920 Mon Sep 17 00:00:00 2001 From: Jin-Sun-tts Date: Wed, 24 Jan 2024 12:25:00 -0500 Subject: [PATCH 3/4] change the message content --- ckanext/geodatagov/templates/package/read.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/geodatagov/templates/package/read.html b/ckanext/geodatagov/templates/package/read.html index c606fadb..6fd68df5 100644 --- a/ckanext/geodatagov/templates/package/read.html +++ b/ckanext/geodatagov/templates/package/read.html @@ -20,7 +20,7 @@

{{ _('Collection') }}

{% snippet "snippets/package_item.html", package=collection_package, truncate=75 %} {% else %} -

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

+

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

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

{% endif %} From 10f58f2b89b6e145ec1c6ca599bc9f67ed8f8916 Mon Sep 17 00:00:00 2001 From: Jin-Sun-tts Date: Wed, 24 Jan 2024 12:26:28 -0500 Subject: [PATCH 4/4] fix typo --- ckanext/geodatagov/templates/package/read.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/geodatagov/templates/package/read.html b/ckanext/geodatagov/templates/package/read.html index 6fd68df5..96d1a34e 100644 --- a/ckanext/geodatagov/templates/package/read.html +++ b/ckanext/geodatagov/templates/package/read.html @@ -20,7 +20,7 @@

{{ _('Collection') }}

{% snippet "snippets/package_item.html", package=collection_package, truncate=75 %} {% else %} -

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

+

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

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

{% endif %}