From 67c100e87797dd3eea9612a02ffbb0d9c7db3301 Mon Sep 17 00:00:00 2001 From: anonymous <anonymous> Date: Fri, 7 Dec 2018 15:42:15 +0100 Subject: [PATCH] ODPSH-152: error string --- ckanext/odsh/fanstatic/odsh_guessformat.js | 1 + .../odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo | Bin 4887 -> 4966 bytes .../odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po | 3 ++ ckanext/odsh/plugin.py | 3 +- ckanext/odsh/templates/macros/form.html | 38 ++++++++++-------- .../package/snippets/resource_form.html | 8 +--- 6 files changed, 29 insertions(+), 24 deletions(-) diff --git a/ckanext/odsh/fanstatic/odsh_guessformat.js b/ckanext/odsh/fanstatic/odsh_guessformat.js index 3efcbff8..8c922753 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 GIT binary patch delta 1358 zcmbQP_Drq*o)F7a1_lO(00ssI83qQ1IZPlP0?V*6FbFX)FvzkpFmN+4Fc`2hFsL#x zFxap{)F-hrFt9Q(Fx0a$Ft9T)FtkF|^|CTB@G~$l%w%O?P-b9YSjo!3z{SA8aF&&U zL6Cug;RY)Mg8~CXJ;N(j1_nt61_o|6h=eK|M4>qw#6l-Fhy{LZ5Ql`YF)*+(FfgRE zF)(m4Ffin?F)&ClFfdd=#V4{s95MrH&H||Z)lm73Yzz#13=9lA*gzhsXJ9za#=xM$ zz`*d9je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.po b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po index f4dd560b..8dda226a 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 93aff5c8..da8a03fb 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 5e8607d8..d519c3fe 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 417553c6..151321c0 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 %} -- GitLab