diff --git a/ckanext/odsh/collection/helpers.py b/ckanext/odsh/collection/helpers.py index cd3f4052e16b1313384d937c8f4f0ce76a60925e..860d2c324194a2626781e8bacb25bb0641d0e222 100644 --- a/ckanext/odsh/collection/helpers.py +++ b/ckanext/odsh/collection/helpers.py @@ -174,5 +174,7 @@ def get_latest_resources_for_format(collection_name, resource_format): if not resources: return None resources_with_asked_type = [r for r in resources if r.get('format').upper() == resource_format.upper()] + if not resources_with_asked_type: + return None resources_sorted = sorted(resources_with_asked_type, key=itemgetter('id','created'), reverse=True) return resources_sorted[-1] diff --git a/ckanext/odsh/collection/plugin.py b/ckanext/odsh/collection/plugin.py index 501f5cade95647b6ac7443ef86fecdabb3d27802..f4265498f966c32d0d64cd874e2cfbcffad22bf1 100644 --- a/ckanext/odsh/collection/plugin.py +++ b/ckanext/odsh/collection/plugin.py @@ -57,7 +57,7 @@ class CollectionsPlugin(plugins.SingletonPlugin, DefaultDatasetForm): url_type = latest_resources.get('url_type') if url_type is None: resource_url = latest_resources.get('url') - toolkit.redirect_to(resource_url) + return toolkit.redirect_to(resource_url) if url_type == 'upload': download_package_id = latest_resources.get('package_id') download_resource_id = latest_resources.get('id')