diff --git a/ckanext/odsh/helpers.py b/ckanext/odsh/helpers.py index fc8a830023bd4b132573e65b06f915e54713ab89..0b7eec7b1e3ab2f3dd6bdc9a487b135c195f5967 100644 --- a/ckanext/odsh/helpers.py +++ b/ckanext/odsh/helpers.py @@ -162,11 +162,9 @@ def odsh_extract_error(key, errors, field='extras'): if 'key' in item: for error in item['key']: if error.startswith(key): - return error.replace(key+':', '') + return error def odsh_extract_error_new(key, errors): - print('ERRORS') - print(errors) if not errors or not ('__extras' in errors): return None error = errors['__extras'][0].get(key,None) diff --git a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo index 15559973318ab1ec1d1fd1212ddb1080d91b222e..3b5f6c5cb8bf495518677cd9f7a31b01781e1e9f 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 409f3d353648b0364de6be191c2d517978e0943b..f680c17b627f88e093dc80c25d0f648b547936f6 100644 --- a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po +++ b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po @@ -171,10 +171,10 @@ msgstr "Dateien" msgid "Spatial uri" msgstr "Raumbezug" -msgid "odsh_spatial_uri_unknown_error_label" +msgid "spatial_uri: uri unknown" msgstr "Der räumliche Bezug is ungültig" -msgid "odsh_spatial_uri_error_label" +msgid "spatial_uri: empty not allowed" msgstr "Bitte geben Sie einen räumlichen Bezug an" msgid "odsh_temporal_start_error_label" diff --git a/ckanext/odsh/templates/package/snippets/package_basic_fields.html b/ckanext/odsh/templates/package/snippets/package_basic_fields.html index 342bebc8fa9139627de7fffc835a1970d1b80ae7..4e585fe7196aac1bc4a90764e20aea25bcca0250 100644 --- a/ckanext/odsh/templates/package/snippets/package_basic_fields.html +++ b/ckanext/odsh/templates/package/snippets/package_basic_fields.html @@ -59,7 +59,7 @@ is_required=true,placeholder=_('Enter title')) }} <!-- field license --> - {% set error_missing_attr = h.odsh_extract_error_new('licenseAttributionByText', errors) %} + {% set error_missing_attr = h.odsh_extract_error('licenseAttributionByText', errors) %} <label class="control-label" for="field-license"> {{ _("License") }}: <span title="{{ _("This field is required") }}" class="control-required">*</span> diff --git a/ckanext/odsh/validation.py b/ckanext/odsh/validation.py index 13c38a249169c5e28cc7aa1af2235501d0ccc2f4..e90bd87098fdc2c30d9492fa60d3d1da6f305ad1 100644 --- a/ckanext/odsh/validation.py +++ b/ckanext/odsh/validation.py @@ -95,30 +95,6 @@ def validate_extra_date_new(key, field, data, optional, errors): pass errors[field] = 'not a valid date' -def validate_extra_date(key, field, data, optional=False): - value = _extract_value(data, field) - - if not value: - if optional: - return - # Statistikamt Nord does not always provide temporal_start/end, - # but their datasets have to be accepted as they are. - if not ('id',) in data or data[('id',)][:7] != 'StaNord': - raise toolkit.Invalid(field+':odsh_'+field+'_error_label') - else: - if re.match(r'\d\d\d\d-\d\d-\d\d', value): - try: - dt=parse(value) - _set_value(data, field, dt.isoformat()) - return - except ValueError: - pass - raise toolkit.Invalid(field+':odsh_'+field+'_not_date_error_label') - - -def validate_extra_date_factory(field, optional=False): - return lambda key, data, errors, context: validate_extra_date(key, field, data, optional) - def validate_licenseAttributionByText(key, data, errors,context): register = model.Package.get_license_register() isByLicense=False @@ -148,11 +124,9 @@ def validate_licenseAttributionByText(key, data, errors,context): if isByLicense and not hasAttribution: raise toolkit.Invalid( - 'licenseAttributionByText:licenseAttributionByText: empty not allowed') + 'licenseAttributionByText: empty not allowed') -# errors['licenseAttributionByText'] = 'empty not allowed' if not isByLicense and hasAttribution: - #errors['licenseAttributionByText'] = 'text not allowed for this license' raise toolkit.Invalid( 'licenseAttributionByText: text not allowed for this license') @@ -164,7 +138,7 @@ def known_spatial_uri(key, data, errors, context): # some harvesters might import a polygon directly... poly = _extract_value(data, 'spatial') if not poly: - raise toolkit.Invalid('spatial_uri:odsh_spatial_uri_error_label') + raise toolkit.Invalid('spatial_uri: empty not allowed') else: return @@ -187,7 +161,7 @@ def known_spatial_uri(key, data, errors, context): break if not_found: raise toolkit.Invalid( - 'spatial_uri:odsh_spatial_uri_unknown_error_label') + 'spatial_uri: uri unknown') # Get the current extras index current_indexes = [k[1] for k in data.keys()