diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index 1cedd76010009413e24bf73472655c4745bf6d7c..bede7281c3ad7717131c462f0910ce1af8541b29 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -71,7 +71,7 @@ def known_spatial_uri(key, data, errors, context): try: mapping_file = urllib2.urlopen(mapping_file) except Exception: - print('Could not load spatial mapping file!') + raise toolkit.Invalid("Could not load spatial mapping file!") not_found = True spatial_text = str() @@ -81,7 +81,9 @@ def known_spatial_uri(key, data, errors, context): if row[0] == data[key]: not_found = False spatial_text = row[1] - spatial = row[2] + loaded = json.loads(row[2]) + spatial = json.dumps(loaded['geometry']) + print spatial break if not_found: raise toolkit.Invalid("The specified URI is not known.") @@ -210,7 +212,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm schema.update({field: [ toolkit.get_converter('not_empty'), toolkit.get_validator('ignore_missing'), - toolkit.get_validator('known_spatial_uri'), + toolkit.get_converter('known_spatial_uri'), toolkit.get_converter('convert_to_extras')]}) else: schema.update({field: [ diff --git a/ckanext/odsh/templates/package/snippets/package_basic_fields.html b/ckanext/odsh/templates/package/snippets/package_basic_fields.html index c22327c65c39dc8d6fff27a6ad97a64be0c21a5e..f060872070793bb669ee84c46ff087efad3a6cfc 100644 --- a/ckanext/odsh/templates/package/snippets/package_basic_fields.html +++ b/ckanext/odsh/templates/package/snippets/package_basic_fields.html @@ -3,6 +3,7 @@ <!-- field title --> {% block package_basic_fields_title %} +{{errors}} {% set error_string = _(_('Title') + ': '+errors.title[0]) if errors.title %} {{ form.input('title', id='field-title', label=_('Title'), value=data.title, error=error_string, classes=['control-full'], attrs={'data-module': 'slug-preview-target'},