added spatial field to schema

This commit is contained in:
Elia Bellavista 2024-06-05 15:19:56 +02:00
parent ad2a842f64
commit 005f75fdd1
1 changed files with 17 additions and 1 deletions

View File

@ -40,6 +40,7 @@ def remove_check_replicated_custom_key(schema):
return schema
#CREATED BY FRANCESCO MANGIACRAPA FOR OVERRIDING THE package_extras_save FROM dictization.model_save.py
#removed in ckan 2.10
def _package_extras_save(extra_dicts, obj, context):
''' It can save repeated extras as key-value '''
allow_partial_update = context.get("allow_partial_update", False)
@ -252,6 +253,11 @@ class D4Science_ThemePlugin(plugins.SingletonPlugin, toolkit.DefaultDatasetForm)
def create_package_schema(self):
# let's grab the default schema in our plugin
schema = super(D4Science_ThemePlugin, self).create_package_schema()
schema.update({
'spatial': [
toolkit.get_validator('ignore_missing'),
toolkit.get_converter('convert_to_extras')]
})
schema = remove_check_replicated_custom_key(schema)
#d.package_dict_save = _package_dict_save
return schema
@ -259,12 +265,22 @@ class D4Science_ThemePlugin(plugins.SingletonPlugin, toolkit.DefaultDatasetForm)
#IDatasetForm
def update_package_schema(self):
schema = super(D4Science_ThemePlugin, self).update_package_schema()
schema.update({
'spatial': [
toolkit.get_validator('ignore_missing'),
toolkit.get_converter('convert_to_extras')]
})
schema = remove_check_replicated_custom_key(schema)
return schema
#IDatasetForm
def show_package_schema(self):
schema = super(D4Science_ThemePlugin, self).show_package_schema()
schema.update({
'spatial': [
toolkit.get_converter('convert_from_extras'),
toolkit.get_validator('ignore_missing')]
})
schema = remove_check_replicated_custom_key(schema)
return schema
@ -321,7 +337,7 @@ class D4Science_ThemePlugin(plugins.SingletonPlugin, toolkit.DefaultDatasetForm)
}
#Overriding package_extras_save method
model_save.package_extras_save = _package_extras_save
# model_save.package_extras_save = _package_extras_save #rimuovo in ckan 2.10
#Overriding index home controller - rimosso in ckan 2.10
#d4sHC = d4SHomeController()