Skip to content
Snippets Groups Projects
Commit 6a095863 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Fixed latest resource for collection

Closes #67
parent 863b9acd
Branches
Tags
1 merge request!50Upgraded to CKAN 2.10
......@@ -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]
......@@ -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')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment