diff --git a/ckanext/odsh/fanstatic/odsh_guessformat.js b/ckanext/odsh/fanstatic/odsh_guessformat.js index 3efcbff85782b72b22f5dadc325a364ef6022ecf..8c922753bd67ee6700c7602dad3c8fcba5380590 100644 --- a/ckanext/odsh/fanstatic/odsh_guessformat.js +++ b/ckanext/odsh/fanstatic/odsh_guessformat.js @@ -7,6 +7,7 @@ ckan.module('odsh_guessformat', function ($) let c = $('#field-format') let onChange = function (filename) { + console.log(known_formats) let ext = filename.slice((filename.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase(); if (ext !== undefined && known_formats.indexOf(ext) > -1) { diff --git a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo index 173ee064cb100313b273394e6ebb9789255edd06..7be3b9dd8e3005b739e5a055e89edb4793ba60ca 100644 Binary files a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo and b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo differ diff --git a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po index f4dd560b8800d12353237f0364bb65bf183423aa..8dda226ad3d0a6e2c548bd8182fcc110b9f37c11 100644 --- a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po +++ b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po @@ -210,6 +210,9 @@ msgstr "Bitte geben sie einen Namen für den Datensatz ein" msgid "odsh_resource_description_error_label" msgstr "Bitte beschreiben Sie Ihren Datensatz" +msgid "odsh_resource_format_error_label" +msgstr "Bitte geben Sie ein Format an" + msgid "Followers" msgstr "Abonennten" diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index 93aff5c8d2ce526a2c214584482f417f3c2a154c..da8a03fb3d2c883565ae78227e7eb1d8c4d324a8 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -265,7 +265,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm schema['tag_string'][i] = odsh_tag_string_convert schema['resources'].update({ - 'url' : [ toolkit.get_converter('not_empty') ] + 'url' : [ toolkit.get_converter('not_empty') ], + 'format' : [ toolkit.get_converter('not_empty') ] }) def create_package_schema(self): diff --git a/ckanext/odsh/templates/macros/form.html b/ckanext/odsh/templates/macros/form.html index 5e8607d825eb05221c950d27d68848f7975314a9..d519c3fe383ccc1aae8d1135473145a52cb1d335 100644 --- a/ckanext/odsh/templates/macros/form.html +++ b/ckanext/odsh/templates/macros/form.html @@ -26,13 +26,17 @@ is_required=false) %} {% call input_block(id or name, label, error, classes, extra_html=extra_html, is_required=is_required) %} <div class="row-fluid"> - <div class="span6"> - <input id="{{ id or name }}" type="{{ _type }}" name="{{ name }}" value="{{ value | empty_and_escape }}" placeholder="{{ placeholder }}" - {{ onFocus }} {{ attributes(attrs) }} /> - </div> - <div class="span6 inline-error"> - {{error}} - </div> + <div class="span6"> + <input id="{{ id or name }}" type="{{ _type }}" name="{{ name }}" value="{{ value | empty_and_escape }}" + placeholder="{{ placeholder }}" {{ onFocus }} {{ attributes(attrs) }} /> + </div> + <div class="span6 inline-error"> + {% if error is string %} + {{error}} + {% else %} + {{error|first}} + {% endif %} + </div> </div> {% endcall %} {% endmacro %} @@ -45,7 +49,7 @@ is_required=false) %} {% call input_block(id or name, label, error, classes, extra_html=extra_html, is_required=is_required) %} <input id="{{ id or name }}" type="{{ _type }}" name="{{ name }}" value="{{ value | empty_and_escape }}" placeholder="{{ placeholder }}" - {{ onFocus }} {{ attributes(attrs) }} /> + {{ onFocus }} {{ attributes(attrs) }} /> {% endcall %} {% endmacro %} @@ -157,14 +161,14 @@ options - A list/tuple of fields to be used as <options>. {% call input_block(id or name, label or name, error, classes, control_classes=["editor"], extra_html=extra_html, is_required=is_required) %} <div class="row-fluid"> - <div class="span6"> - <textarea id="{{ id or name }}" name="{{ name }}" cols="20" rows="5" placeholder="{{ placeholder }}" - {{ attributes(attrs) }}>{{ value | empty_and_escape }}</textarea> - </div> - <div class="span6 inline-error"> - {{error}} - </div> - </div> + <div class="span6"> + <textarea id="{{ id or name }}" name="{{ name }}" cols="20" rows="5" placeholder="{{ placeholder }}" + {{ attributes(attrs) }}>{{ value | empty_and_escape }}</textarea> + </div> + <div class="span6 inline-error"> + {{error}} + </div> + </div> {% endcall %} {% endmacro %} @@ -493,4 +497,4 @@ options - A list/tuple of fields to be used as <options>. {% if is_upload_enabled %}</div>{% endif %} - {% endmacro %} + {% endmacro %} \ No newline at end of file diff --git a/ckanext/odsh/templates/package/snippets/resource_form.html b/ckanext/odsh/templates/package/snippets/resource_form.html index 417553c637e3e490b5214a1aeb44d63ddac82529..151321c001bffb96a6e1bb57a55c1b3030b3d3f4 100644 --- a/ckanext/odsh/templates/package/snippets/resource_form.html +++ b/ckanext/odsh/templates/package/snippets/resource_form.html @@ -1,4 +1,3 @@ - {% resource 'odsh/odsh_image-upload.js' %} {% import 'macros/form.html' as form %} @@ -72,12 +71,9 @@ {% resource 'odsh/odsh_guessformat.js' %} {% set format_attrs = {'data-module': 'odsh_guessformat', 'data-module-formats':h.odsh_upload_known_formats()} %} + {% set error_string = _('odsh_resource_format_error_label') if errors.format %} - {% 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) %} - <span class="info-block info-block-small"> - <i class="fa fa-info-circle"></i> - {{ _('This will be guessed automatically. Leave blank if you wish') }} - </span> + {% call form.input('format', id='field-format', label=_('Format'), placeholder=_('eg. CSV, XML or JSON'), value=data.format, error=error_string, classes=['control-medium'],attrs=format_attrs) %} {% endcall %} {% endblock %} {% endblock %}