From 703320364ff5e40165f9008d9c943d75e2cb44ac Mon Sep 17 00:00:00 2001 From: Konstantin Sivakov Date: Wed, 28 Nov 2018 13:04:11 +0100 Subject: [PATCH] Revert last commit, add the striping logic in the resource dictize --- ckan/lib/dictization/model_dictize.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ckan/lib/dictization/model_dictize.py b/ckan/lib/dictization/model_dictize.py index 644437147b7..61731812aaf 100644 --- a/ckan/lib/dictization/model_dictize.py +++ b/ckan/lib/dictization/model_dictize.py @@ -108,14 +108,15 @@ def resource_dictize(res, context): ## for_edit is only called at the times when the dataset is to be edited ## in the frontend. Without for_edit the whole qualified url is returned. if resource.get('url_type') == 'upload' and not context.get('for_edit'): + url = url.rsplit('/')[-1] cleaned_name = munge.munge_filename(url) resource['url'] = h.url_for('resource.download', id=resource['package_id'], resource_id=res.id, filename=cleaned_name, qualified=True) - elif resource['url'] and not urlparse.urlsplit(url).scheme: - res_dict['url'] = res_dict['url'].rsplit('/')[-1] + elif resource['url'] and not urlparse.urlsplit(url).scheme and not context.get('for_edit'): + resource['url'] = u'http://' + url.lstrip('/') return resource