Skip to content

Commit

Permalink
[#2570] Fix IGroupForm check_data_dict not being called
Browse files Browse the repository at this point in the history
Make group_create() and group_update() call the check_data_dict()
methods of IGroupForm plugins, like package_create() and
package_update() do with IDatasetForm plugins.
  • Loading branch information
Sean Hammond committed Aug 1, 2012
1 parent 3ed510b commit 5c63f30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ckan/logic/action/create.py
Expand Up @@ -512,6 +512,14 @@ def group_create(context, data_dict):
except AttributeError:
schema = group_plugin.form_to_db_schema()

if 'api_version' not in context:
# old plugins do not support passing the schema so we need
# to ensure they still work
try:
group_plugin.check_data_dict(data_dict, schema)
except TypeError:
group_plugin.check_data_dict(data_dict)

data, errors = _validate(data_dict, schema, context)
log.debug('group_create validate_errs=%r user=%s group=%s data_dict=%r',
errors, context.get('user'), data_dict.get('name'), data_dict)
Expand Down
8 changes: 8 additions & 0 deletions ckan/logic/action/update.py
Expand Up @@ -415,6 +415,14 @@ def group_update(context, data_dict):

_check_access('group_update', context, data_dict)

if 'api_version' not in context:
# old plugins do not support passing the schema so we need
# to ensure they still work
try:
group_plugin.check_data_dict(data_dict, schema)
except TypeError:
group_plugin.check_data_dict(data_dict)

data, errors = _validate(data_dict, schema, context)
log.debug('group_update validate_errs=%r user=%s group=%s data_dict=%r',
errors, context.get('user'),
Expand Down

0 comments on commit 5c63f30

Please sign in to comment.