From 8596191d1bf4aa9fc418c017204c54f413b3bd08 Mon Sep 17 00:00:00 2001 From: Nigel Babu Date: Mon, 19 Aug 2013 13:45:48 +0530 Subject: [PATCH] [#880] Don't add ckan.url and add url_type field --- ckan/public/base/javascript/client.js | 8 +++++--- ckan/templates/package/snippets/resource_form.html | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ckan/public/base/javascript/client.js b/ckan/public/base/javascript/client.js index 45940c0086d..971a09d2244 100644 --- a/ckan/public/base/javascript/client.js +++ b/ckan/public/base/javascript/client.js @@ -26,7 +26,7 @@ }, /* Simple helper function for both GET's and POST's to the ckan API - * + * * type - GET or POST * path - The API endpoint * data - Any data you need passing to the endpoint @@ -320,15 +320,17 @@ var filename = meta['filename-original'] || meta.key; var format = meta._format || filename.split('.').pop(); var url = meta._location; + var url_type = null // If this is a local upload then the returned url will not have a domain - // and we should add one. + // and we should mark it as a filestore url. if (url.indexOf('://') === -1) { - url = ckan.url(url); + url_type = 'filestore'; } return { url: url, + url_type: url_type, key: meta.key, /* Not strictly Resource data but may be useful */ name: filename, size: meta._content_length, diff --git a/ckan/templates/package/snippets/resource_form.html b/ckan/templates/package/snippets/resource_form.html index 397d3d2504d..25666376c87 100644 --- a/ckan/templates/package/snippets/resource_form.html +++ b/ckan/templates/package/snippets/resource_form.html @@ -49,6 +49,10 @@ {{ form.markdown('description', id='field-description', label=_('Description'), placeholder=_('Some useful notes about the data'), value=data.description, error=errors.description) }} {% endblock %} + {% block basic_fields_url_type %} + + {% endblock %} + {% block basic_fields_format %} {% set format_attrs = {'data-module': 'autocomplete', 'data-module-source': '/api/2/util/resource/format_autocomplete?incomplete=?'} %} {% call form.input('format', id='field-format', label=_('Format'), placeholder=_('eg. CSV, XML or JSON'), value=data.format, error=errors.format, classes=['control-medium'], attrs=format_attrs) %}