From 45d1639b40f303466572d7c701c9bac273dbf03b Mon Sep 17 00:00:00 2001 From: anonymous <anonymous> Date: Fri, 2 Nov 2018 14:08:31 +0100 Subject: [PATCH] ODPSH-81: Applies layout changes according to Mockup --- ckanext/odsh/helpers.py | 26 +++--- .../odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo | Bin 2977 -> 3347 bytes .../odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po | 20 ++++- ckanext/odsh/plugin.py | 4 +- ckanext/odsh/public/odsh.css | 18 +++- ckanext/odsh/templates/macros/form.html | 38 +++++++-- .../templates/package/base_form_page.html | 37 +++++++- .../odsh/templates/package/new_resource.html | 4 +- .../snippets/package_basic_fields.html | 79 +++++++++++------- .../package/snippets/package_form.html | 13 +-- .../package/snippets/resource_form.html | 14 ++-- 11 files changed, 184 insertions(+), 69 deletions(-) diff --git a/ckanext/odsh/helpers.py b/ckanext/odsh/helpers.py index 308c92fe..10b5675b 100644 --- a/ckanext/odsh/helpers.py +++ b/ckanext/odsh/helpers.py @@ -7,17 +7,19 @@ log = logging.getLogger(__name__) def odsh_openness_score_dataset_html(dataset): score = 0 + #dataset = json.loads(dataset) resources = dataset.get('resources') - if resources: - for resource in resources: - r_qa = resource.get('qa') - if r_qa: - try: - qa = ast.literal_eval(r_qa) - resource_score = qa.get('openness_score') - if resource_score > score: - score = resource_score - except AttributeError, e: - log.error('Error while calculating openness score %s: %s\nException: %s', - e.__class__.__name__, unicode(e), traceback.format_exc()) + if resources is None: + return 0 + for resource in resources: + r_qa = resource.get('qa') + if r_qa: + try: + qa = ast.literal_eval(r_qa) + resource_score = qa.get('openness_score') + if resource_score > score: + score = resource_score + except AttributeError, e: + log.error('Error while calculating openness score %s: %s\nException: %s', + e.__class__.__name__, unicode(e), traceback.format_exc()) return score diff --git a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo index b5f7363d12c70bcf124ea3f4569043af2c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Db1byfJ1b1 QB9}Si<U?GdlUsQD0Um*62><{9 diff --git a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po index f98d9077..fdd98232 100644 --- a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po +++ b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po @@ -110,7 +110,7 @@ msgid "Beginn des Zeitraumes: Fehlender Wert" msgstr "Bitte wählen Sie einen Beginn des Zeitraumes aus" msgid "Ende des Zeitraumes: Fehlender Wert" -msgstr "Bitte wählen Sie ein Ende des Zeitraumes aus" +msgstr "Bitte wählen Sie einen Zeitraum aus" msgid "Name: Fehlender Wert" msgstr "Bitte geben Sie eine Url ein" @@ -121,7 +121,7 @@ msgstr "Bitte geben Sie einen Ort ein" msgid "Tags" msgstr "Schlagwörter" -msgid "Notes: Fehlender Wert" +msgid "Beschreibung: Fehlender Wert" msgstr "Bitte geben Sie eine Beschreibung ein" msgid "Namensnennung: Fehlender Wert" @@ -130,12 +130,24 @@ msgstr "Bitte geben Sie einen Namen ein" msgid "Titel: Fehlender Wert" msgstr "Bitte geben Sie einen Titel ein" -msgid "Publish date: Fehlender Wert" -msgstr "Bitte wählen Sie ein Veröffetlichungsdatum" +msgid "odsh_publish_date_error_label" +msgstr "Bitte wählen Sie ein Veröffentlichungsdatum" + +msgid "odsh_spatial_extension_error_label" +msgstr "Bitte geben sie einen räumlichen Bezug an" msgid "Tag string: Fehlender Wert" msgstr "Bitte wählen Sie geeignete Schlagwörter" +msgid "odsh_resource_upload_error_label" +msgstr "Bitte laden Sie Ihren Datensatz hoch" + +msgid "odsh_resource_name_error_label" +msgstr "Bitte geben sie einen Namen für den Datensatz ein" + +msgid "odsh_resource_description_error_label" +msgstr "Bitte beschreiben Sie Ihren Datensatz" + msgid "Followers" msgstr "Abonennten" diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index aad1ae8c..1f50abaf 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -122,7 +122,9 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm # # toolkit.get_converter('not_empty'), # toolkit.get_converter('odsh_convert_groups_string')] }) schema['resources'].update({ - 'url' : [ toolkit.get_converter('not_empty') ] + 'url' : [ toolkit.get_converter('not_empty') ], + 'description' : [ toolkit.get_converter('not_empty') ], + 'name' : [ toolkit.get_converter('not_empty') ] }) def create_package_schema(self): diff --git a/ckanext/odsh/public/odsh.css b/ckanext/odsh/public/odsh.css index 12ea178d..392473fd 100644 --- a/ckanext/odsh/public/odsh.css +++ b/ckanext/odsh/public/odsh.css @@ -361,7 +361,7 @@ label:after { border-radius: 0; } -.control-group.error .control-label, .control-group.error .help-block, .control-group.error .help-inline { +.control-label, .control-group.error .control-label, .control-group.error .help-block, .control-group.error .help-inline { color: black; } @@ -606,4 +606,18 @@ label:after { } .create-dataset-form{ - width: 50%;} \ No newline at end of file + width: 50%; +} + +.primary.span12 { + width: 100%; +} + +.inline-error { + color: #d4004b; + margin-top: 5px; +} + +.controls select { + width: 100%; +} diff --git a/ckanext/odsh/templates/macros/form.html b/ckanext/odsh/templates/macros/form.html index 4cb10b2f..2a847d9d 100644 --- a/ckanext/odsh/templates/macros/form.html +++ b/ckanext/odsh/templates/macros/form.html @@ -24,9 +24,28 @@ is_required=false) %} {%- set _type = 'text' if type=='date' and not value else type -%} {%- set onFocus = 'onfocus=(this.type=\'date\')' if type=='date' and not value else '' -%} +{% 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> +{% endcall %} +{% endmacro %} + +{% macro input_raw(name, id='', label='', value='', placeholder='', type='text', error="", classes=[], attrs={}, +is_required=false) %} +{%- set extra_html = caller() if caller -%} +{%- set _type = 'text' if type=='date' and not value else type -%} +{%- set onFocus = 'onfocus=(this.type=\'date\')' if type=='date' and not value else '' -%} + {% 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 %} @@ -137,8 +156,15 @@ options - A list/tuple of fields to be used as <options>. {%- set extra_html = caller() if caller -%} {% call input_block(id or name, label or name, error, classes, control_classes=["editor"], extra_html=extra_html, is_required=is_required) %} - <textarea id="{{ id or name }}" name="{{ name }}" cols="20" rows="5" placeholder="{{ placeholder }}" - {{ attributes(attrs) }}>{{ value | empty_and_escape }}</textarea> + <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> {% endcall %} {% endmacro %} @@ -454,11 +480,11 @@ options - A list/tuple of fields to be used as <options>. {% endif %} {{ input(field_url, label=url_label, id='field-image-url', placeholder=placeholder, - value=data.get(field_url), error=errors.get(field_url), classes=['control-full']) }} + value=data.get(field_url), error='', classes=['control-full']) }} {% if is_upload_enabled %} {{ input(field_upload, label=upload_label, id='field-image-upload', type='file', placeholder='', value='', - error='', classes=['control-full'], is_required=true) }} + error=errors, classes=['control-full'], is_required=true) }} {% if is_upload %} {{ checkbox(field_clear, label=_('Clear Upload'), id='field-clear-upload', value='true', error='', classes=['control-full']) }} @@ -467,4 +493,4 @@ options - A list/tuple of fields to be used as <options>. {% if is_upload_enabled %}</div>{% endif %} - {% endmacro %} \ No newline at end of file + {% endmacro %} diff --git a/ckanext/odsh/templates/package/base_form_page.html b/ckanext/odsh/templates/package/base_form_page.html index 3e321e79..b5ac492b 100644 --- a/ckanext/odsh/templates/package/base_form_page.html +++ b/ckanext/odsh/templates/package/base_form_page.html @@ -1,3 +1,36 @@ {% ckan_extends %} -{% block secondary%} -{% endblock %} \ No newline at end of file + + {% block main_content %} + + {% block flash %} + {{ super() }} + {% endblock %} + + {% block toolbar %} + {{ super() }} + {% endblock %} + + <div class="row wrapper{% block wrapper_class %}{% endblock %}{% if self.secondary()|trim == '' %} no-nav{% endif %}"> + {# + The pre_primary block can be used to add content to before the + rendering of the main content columns of the page. + #} + {% block pre_primary %} + {% endblock %} + + {% block secondary %} + {% endblock %} + + {% block primary %} + <div class="primary span12"> + {% block primary_content %} + {{ super() }} + {% endblock %} + </div> + {% endblock %} + + </div> + {% endblock %} + + + diff --git a/ckanext/odsh/templates/package/new_resource.html b/ckanext/odsh/templates/package/new_resource.html index 18919d58..31afa253 100644 --- a/ckanext/odsh/templates/package/new_resource.html +++ b/ckanext/odsh/templates/package/new_resource.html @@ -16,10 +16,10 @@ include_metadata=false, pkg_name=pkg_name, stage=stage, allow_upload=g.ofs_impl and logged_in, dataset_type=dataset_type %}{% endblock %} -{% block secondary_content %} +{% block secondary %} {% endblock %} {% block scripts %} {{ super() }} {% resource 'vendor/fileupload' %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/ckanext/odsh/templates/package/snippets/package_basic_fields.html b/ckanext/odsh/templates/package/snippets/package_basic_fields.html index c372f3c5..591dd379 100644 --- a/ckanext/odsh/templates/package/snippets/package_basic_fields.html +++ b/ckanext/odsh/templates/package/snippets/package_basic_fields.html @@ -4,8 +4,9 @@ <!-- field title --> {% block package_basic_fields_title %} +{% set error_string = _(_('Title') + ': '+errors.title[0]) if errors.title %} {{ form.input('title', id='field-title', label=_('Title'), value=data.title, -error=errors.title, classes=['control-full', 'control-large'], attrs={'data-module': 'slug-preview-target'}, +error=error_string, classes=['control-full'], attrs={'data-module': 'slug-preview-target'}, is_required=true,placeholder=_('Enter title')) }} {% endblock %} @@ -23,23 +24,25 @@ is_required=true,placeholder=_('Enter title')) }} <!-- field notes --> {% block package_basic_fields_description %} + {% set error_string = _(_('Description') + ': '+errors.notes[0]) if errors.notes %} {{ form.markdown('notes', id='field-notes', label=_('Description'), value=data.notes, - error=errors.notes, is_required=true, placeholder=_('Enter description')) }} + error=error_string, is_required=true, placeholder=_('Enter description')) }} {% endblock %} <!-- field license --> + <label class="control-label" for="field-license"> {{ _("License") }}: <span title="{{ _("This field is required") }}" class="control-required">*</span> </label> - <div class='row'> - <div class='span4'> + <div class='row-fluid'> + <div class='span3'> {% block package_basic_fields_license %} <div class="control-group"> {% set error = errors.license_id %} <div class="controls"> - <select id="field-license" name="license_id" class="span4"> + <select id="field-license" name="license_id"> {% set existing_license_id = data.get('license_id') %} {% for license_id, license_desc in h.license_options(existing_license_id) %} <option value="{{ license_id }}" {% if existing_license_id==license_id %}selected="selected" {% @@ -50,49 +53,55 @@ is_required=true,placeholder=_('Enter title')) }} </div> </div> </div> - <div class='span1'></div> - <div class='span4'> + <div class='span3'> <!-- field Namensnennung --> - {{ form.input('access_constraints', id='field-licence-name', value=data.access_constraints, + {{ form.input_raw('access_constraints', id='field-licence-name', value=data.access_constraints, error=errors.access_constraints, - classes=['control-full span4'],type='text',is_required=true,attrs={'disabled':true, + classes=['control-full'],type='text',is_required=true,attrs={'disabled':true, 'data-module':"odsh_form", 'data-module-licensetoggle':'true' }, placeholder=_('enter name')) }} </div> + <div class="span6 inline-error"> + {{error}} + </div> </div> {% endblock %} <!-- timerange --> - <div class='row'> - <label for="start-end" class="control-label">{{ _('timerange') }}: - <span title="{{ _("This field is required") }}" class="control-required">*</span> - </label> - <div id='start-end' class='span4'> + {% set error_string = _(_('Temporal end') + ': '+errors.temporal_end[0]) if errors.temporal_end %} + <label for="start-end" class="control-label">{{ _('timerange') }}: + <span title="{{ _("This field is required") }}" class="control-required">*</span> + </label> + <div class='row-fluid'> + <div id='start-end' class='span3'> <!-- field temporal_start --> {% set temporal_start_label=_('odsh_temporal_start_label') %} - {{ form.input('temporal_start', id='field-temporal-start', value=data.temporal_start, + {{ form.input_raw('temporal_start', id='field-temporal-start', value=data.temporal_start, error=errors.temporal_start, classes=['control-full'],type='date',is_required=true,placeholder=_('from')) }} </div> - <div class='span1'></div> - <div class='span4'> + <div class='span3'> <!-- field temporal_end --> {% set temporal_end_label='Ende des Zeitraumes' %} - {{ form.input('temporal_end', id='field-temporal-end', value=data.temporal_end, + {{ form.input_raw('temporal_end', id='field-temporal-end', value=data.temporal_end, error=errors.temporal_end, classes=['control-full'],type='date',is_required=true, placeholder=_('to')) }} </div> + <div class="span6 inline-error"> + {{error_string}} + </div> </div> <!-- field publish date --> {% set publish_date_value=h.odsh_now() %} + {% set error_string = _('odsh_publish_date_error_label') if errors.publish_date %} <!-- if form_style != 'edit' && !%} --> <!-- value=data.get('extras').publish_date, --> {% set publish_date_label='Veröffentlichungsdatum'%} {{ form.input('publish_date', id='field-publish-date', label=publish_date_label, value=publish_date_value, - error=errors.publish_date, classes=['control-full'],type='date',is_required=true) }} + error=error_string, classes=['control-full'],type='date',is_required=true) }} <!-- field tags --> @@ -110,22 +119,28 @@ is_required=true,placeholder=_('Enter title')) }} {% endblock %} <!-- field spatial_extension --> + {% set error_string = _('odsh_spatial_extension_error_label') if errors.spatial_extension %} {{ form.input('spatial_extension', id='field-spatial-extension', label=_('Spatial extension'), value=data.spatial_extension, - error=errors.spatial_extension, classes=['control-full'],type='text',is_required=true, + error=error_string, classes=['control-full'],type='text',is_required=true, placeholder=_('Enter spatial extension')) }} + <!-- field private --> <div class="control-group"> <label for="field-private" class="control-label">{{ _('Visibility') }}: <span title="{{ _("This field is required") }}" class="control-required">*</span> </label> <div class="controls"> - <select id="field-private" name="private"> + <div class="row-fluid"> + <div class="span6"> + <select id="field-private" name="private"> {% for option in [('True', _('Private')), ('False', _('Public'))] %} <option value="{{ option[0] }}" {% if option[0]==data.private|trim %}selected="selected" {% endif %}>{{ - option[1] }}</option> + option[1] }}</option> {% endfor %} - </select> + </select> + </div> + </div> </div> </div> @@ -134,12 +149,16 @@ is_required=true,placeholder=_('Enter title')) }} <div class="control-group"> <label for="field-state" class="control-label">{{ _('State') }}</label> <div class="controls"> - <select id="field-state" name="state"> - <option value="active" {% if data.get('state', 'none' )=='active' %} selected="selected" {% endif %}>{{ - _('Active') }}</option> - <option value="deleted" {% if data.get('state', 'none' )=='deleted' %} selected="selected" {% endif %}>{{ - _('Deleted') }}</option> - </select> + <div class="row-fluid"> + <div class="span6"> + <select id="field-state" name="state"> + <option value="active" {% if data.get('state', 'none' )=='active' %} selected="selected" {% endif %}>{{ + _('Active') }}</option> + <option value="deleted" {% if data.get('state', 'none' )=='deleted' %} selected="selected" {% endif %}>{{ + _('Deleted') }}</option> + </select> + </div> + </div> </div> </div> - {% endif %} \ No newline at end of file + {% endif %} diff --git a/ckanext/odsh/templates/package/snippets/package_form.html b/ckanext/odsh/templates/package/snippets/package_form.html index c5e56718..4d18903e 100644 --- a/ckanext/odsh/templates/package/snippets/package_form.html +++ b/ckanext/odsh/templates/package/snippets/package_form.html @@ -11,7 +11,7 @@ then itself be extended to add/remove blocks of functionality. #} <input type="hidden" name="_ckan_phase" value="dataset_new_1" /> {# pkg_name used in 3 stage edit #} <input type="hidden" name="pkg_name" value="{{ data.id }}" /> - {% block errors %}{{ form.errors(error_summary) }}{% endblock %} + {# {% block errors %}{{ form.errors(error_summary) }}{% endblock %} #} {% block basic_fields %} {% snippet 'package/snippets/package_basic_fields.html', data=data, errors=errors, licenses=c.licenses, @@ -32,10 +32,13 @@ then itself be extended to add/remove blocks of functionality. #} {% endif %} {% endblock %} {% block save_button %} - <button class="btn btn-primary" type="submit" name="save">{% block save_button_text %}{{ _('Next: Add Data') - }}{% - endblock %}</button> + <div class="row-fluid"> + <div class="span6"> + <button class="btn btn-primary" type="submit" name="save">{% block save_button_text %}{{ _('Next: Add Data') + }}{% endblock %}</button> + </div> + </div> {% endblock %} </div> {% endblock %} -</form> \ No newline at end of file +</form> diff --git a/ckanext/odsh/templates/package/snippets/resource_form.html b/ckanext/odsh/templates/package/snippets/resource_form.html index 8d753890..610c2b42 100644 --- a/ckanext/odsh/templates/package/snippets/resource_form.html +++ b/ckanext/odsh/templates/package/snippets/resource_form.html @@ -16,27 +16,31 @@ {% endif %} {% endblock %} - {% block errors %}{{ form.errors(error_summary) }}{% endblock %} + {# {% block errors %}{{ form.errors(error_summary) }}{% endblock %} #} <input name="id" value="{{ data.id }}" type="hidden" /> {% block basic_fields %} + {% block basic_fields_url %} {% set is_upload = (data.url_type == 'upload') %} - {{ form.image_upload(data, errors, field_url='url', field_upload='upload', field_clear='clear_upload', + {% set error_string = _('odsh_resource_upload_error_label') if error_summary %} + {{ form.image_upload(data, error_string, field_url='url', field_upload='upload', field_clear='clear_upload', is_upload_enabled=h.uploads_enabled(), is_url=data.url and not is_upload, is_upload=is_upload, upload_label=_('Data-Upload'), url_label=_('URL'), placeholder=_('http://example.com/external-data.csv'), field_name='name') }} {% endblock %} {% block basic_fields_name %} + {% set error_string = _('odsh_resource_name_error_label') if errors.name %} {{ form.input('name', id='field-name', label=_('Name'), placeholder=_('Enter name of the dataset'), - value=data.name, error=errors.name, classes=['control-full'], is_required=true) }} + value=data.name, error=error_string, classes=['control-full'], is_required=true) }} {% endblock %} {% block basic_fields_description %} + {% set error_string = _('odsh_resource_description_error_label') if errors.description %} {{ form.markdown('description', id='field-description', label=_('Description'), - placeholder=_('Enter description of the dataset'), value=data.description, error=errors.description, + placeholder=_('Enter description of the dataset'), value=data.description, error=error_string, is_required=true) }} {% endblock %} @@ -93,4 +97,4 @@ {% endblock %} {% endif %} </div> -</form> \ No newline at end of file +</form> -- GitLab