Skip to content

Commit 3e3eebf

Browse files
committed
fix(templates): <=2.10 template additions, falsy url type;
- Added old template blocks for version 2.10 and less. - Added falsy check on url_type in template helper method.
1 parent b060bdc commit 3e3eebf

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

ckanext/xloader/helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ def is_resource_supported_by_xloader(res_dict, check_access = True):
3838
try:
3939
is_supported_url_type = res_dict.get('url_type') not in toolkit.h.datastore_rw_resource_url_types()
4040
except AttributeError:
41-
is_supported_url_type = (res_dict.get('url_type') == 'upload' or res_dict.get('url_type') == '')
41+
is_supported_url_type = (res_dict.get('url_type') == 'upload' or not res_dict.get('url_type'))
4242
return (is_supported_format or is_datastore_active) and user_has_access and is_supported_url_type

ckanext/xloader/templates/package/resource_read.html

+7
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@
66
<li>{% link_for _('DataStore'), named_route='xloader.resource_data', id=pkg.name, resource_id=res.id, class_='btn btn-light', icon='cloud-upload' %}</li>
77
{% endif %}
88
{% endblock %}
9+
10+
{% block resource_actions_inner %}
11+
{% if h.check_ckan_version(max_version='2.10') and h.is_resource_supported_by_xloader(res) %}
12+
<li>{% link_for _('DataStore'), named_route='xloader.resource_data', id=pkg.name, resource_id=res.id, class_='btn btn-light', icon='cloud-upload' %}</li>
13+
{% endif %}
14+
{{ super() }}
15+
{% endblock %}

ckanext/xloader/templates/package/snippets/resource_item.html

+7
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@
66
<li>{% link_for _('DataStore'), named_route='xloader.resource_data', id=pkg.name, resource_id=res.id, class_='dropdown-item', icon='cloud-upload' %}</li>
77
{% endif %}
88
{% endblock %}
9+
10+
{% block resource_item_explore_links %}
11+
{% if h.check_ckan_version(max_version='2.10') and h.is_resource_supported_by_xloader(res) %}
12+
<li>{% link_for _('DataStore'), named_route='xloader.resource_data', id=pkg.name, resource_id=res.id, class_='dropdown-item', icon='cloud-upload' %}</li>
13+
{% endif %}
14+
{{ super() }}
15+
{% endblock %}

0 commit comments

Comments
 (0)