[#4] Changes in schema to accommodate organizations

Basically handle the 'owner_org' field in form_to_db and db_to_form.
Added 'owner_org', 'frequency' (has default) and 'config' to surplus
keys in check_data_dict.
Also remove schema tweaks to let package_show call the appropiate schema
function.
This commit is contained in:
amercader 2013-02-11 16:34:52 +00:00
parent 1391948b62
commit eaa8988440
3 changed files with 7 additions and 11 deletions

View File

@ -34,7 +34,6 @@ def harvest_source_show(context,data_dict):
:rtype: dictionary
'''
context['schema'] = harvest_source_db_to_form_schema()
source_dict = logic.get_action('package_show')(context, data_dict)
# For compatibility with old code, add the active field

View File

@ -61,6 +61,7 @@ def harvest_source_db_to_form_schema():
'source_type': [convert_from_extras, ignore_missing],
'frequency': [convert_from_extras, ignore_missing],
'config': [convert_from_extras, ignore_missing],
'owner_org': [ignore_missing]
})
return schema

View File

@ -138,11 +138,7 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
Similar to db_to_form_schema but with further options to allow
slightly different schemas, eg for creation or deletion on the API.
'''
if options.get('type') == 'show':
return None
else:
return self.db_to_form_schema()
return self.db_to_form_schema()
def db_to_form_schema(self):
'''
@ -157,12 +153,11 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
'''Check if the return data is correct, mostly for checking out
if spammers are submitting only part of the form'''
surplus_keys_schema = ['__extras', '__junk', 'extras',
surplus_keys_schema = ['__extras', '__junk', 'extras', 'notes',
'extras_validation', 'save', 'return_to', 'type',
'state']
'state', 'owner_org', 'frequency', 'config']
#TODO: state and delete
if not schema:
schema = self.form_to_db_schema()
schema_keys = schema.keys()
@ -170,8 +165,9 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
missing_keys = keys_in_schema - set(data_dict.keys())
if missing_keys:
log.info('incorrect form fields posted, missing %s' % missing_keys)
raise dictization_functions.DataError(data_dict)
msg = 'Incorrect form fields posted, missing %s' % missing_keys
log.info(msg)
raise dictization_functions.DataError(msg)
def configure(self, config):