Skip to content

Commit

Permalink
[#880] Don't add ckan.url and add url_type field
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelbabu committed Aug 19, 2013
1 parent c78557a commit 8596191
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ckan/public/base/javascript/client.js
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions ckan/templates/package/snippets/resource_form.html
Expand Up @@ -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 %}
<input name='url_type' id='field-url_type' type='hidden' value="{{ data.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) %}
Expand Down

0 comments on commit 8596191

Please sign in to comment.