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') diff --git a/ckanext/odsh/templates/organization/snippets/organization_form.html b/ckanext/odsh/templates/organization/snippets/organization_form.html index 153a5e157735a7ea73ee780c8d2ae2c12008d9c1..77797c54474261d77eb83b6675013d97b46769e3 100644 --- a/ckanext/odsh/templates/organization/snippets/organization_form.html +++ b/ckanext/odsh/templates/organization/snippets/organization_form.html @@ -47,8 +47,8 @@ {{ form.input_address('gnd','GND URI', value=extras.gnd, index=6, placeholder='https://d-nb.info/gnd/1136109587', type='text', attrs={}) }} - <!-- {% for extra in data.extras %} - {% set custom_extras = ['person','street','location','telephone','mail','web','gnd'] %} + {% set custom_extras = ['person','street','location','telephone','mail','web','gnd'] %} + {% for extra in data.extras %} {% if extra.key not in custom_extras %} {% set prefix = 'extras__%d__' % (loop.index0 + (custom_extras|count)) %} {{ form.custom( @@ -63,11 +63,12 @@ {# Add a max of 3 empty columns #} {% set total_extras = data.extras|count %} + {% if total_extras <= (custom_extras|count) %}{% set total_extras = (custom_extras|count) %}{% endif %} {% set empty_extras = (limit or 3) - total_extras %} {% if empty_extras <= 0 %}{% set empty_extras = 1 %}{% endif %} {% for extra in range(total_extras, total_extras + empty_extras) %} - {% set index = loop.index0 + (data.extras|count) + (custom_extras|count) %} + {% set index = loop.index0 + total_extras %} {% set prefix = 'extras__%d__' % index %} {{ form.custom( names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'), @@ -76,7 +77,7 @@ values=(extra.key, extra.value, extra.deleted), error=errors[prefix ~ 'key'] or errors[prefix ~ 'value'] ) }} - {% endfor %} --> + {% endfor %} </div> {% endblock %}