Skip to content
Snippets Groups Projects
Commit 80a5bb75 authored by anonymous's avatar anonymous
Browse files

fix resource url

parent 4484860a
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,8 @@ import urllib
import hashlib
import re
from ckan.common import request
from urlparse import urlsplit, urlunsplit
get_action = logic.get_action
log = logging.getLogger(__name__)
......@@ -215,3 +217,11 @@ def odsh_has_more_facets(facet, limit=None, exclude_active=False):
def odsh_public_url():
return config.get('ckanext.odsh.public_url')
def odsh_public_resource_url(res):
home = config.get('ckanext.odsh.public_url')
if res.get('url_type',None) == 'upload' and 'url' in res:
f = urlsplit(res['url'])
return urlunsplit((0, 0, f[2], f[3], f[4]))
else:
return res['url']
......@@ -289,7 +289,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
'odsh_tracking_id': odsh_helpers.odsh_tracking_id,
'odsh_tracking_url': odsh_helpers.odsh_tracking_url,
'odsh_has_more_facets': odsh_helpers.odsh_has_more_facets,
'odsh_public_url': odsh_helpers.odsh_public_url
'odsh_public_url': odsh_helpers.odsh_public_url,
'odsh_public_resource_url': odsh_helpers.odsh_public_resource_url
}
def after_map(self, map):
......
......@@ -2,13 +2,7 @@
{% set url = h.url_for(controller='package', action=url_action, id=pkg.name, resource_id=res.id) %}
{# hack for correcting slave url if resource was uploaded #}
{% if res.url_type=='upload' %}
{% set download = url or res.url%}
{% else %}
{% set download = res.url or ulr%}
{% endif %}
{% set res_details = h.odsh_get_resource_details(res.id) %}
{% set download = h.odsh_public_resource_url(res) or ulr%}
<li class="resource-item" data-id="{{ res.id }}">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment