Skip to content

Commit

Permalink
[#1795] fix show+update validate calls
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Jun 30, 2014
1 parent cb521c3 commit 01b53cf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions ckan/controllers/package.py
Expand Up @@ -875,8 +875,9 @@ def _save_new(self, context, package_type=None):
# prevent clearing of groups etc
context['allow_partial_update'] = True
# sort the tags
data_dict['tags'] = self._tag_string_to_list(
data_dict['tag_string'])
if 'tag_string' in data_dict:
data_dict['tags'] = self._tag_string_to_list(
data_dict['tag_string'])
if data_dict.get('pkg_name'):
is_an_update = True
# This is actually an update not a save
Expand Down
4 changes: 2 additions & 2 deletions ckan/logic/action/get.py
Expand Up @@ -909,7 +909,7 @@ def package_show(context, data_dict):
if schema and context.get('validate', True):
package_dict, errors = lib_plugins.plugin_validate(
package_plugin, context, package_dict, schema,
'package_show')
'package_show', package_dict['type'])

for item in plugins.PluginImplementations(plugins.IPackageController):
item.after_show(context, package_dict)
Expand Down Expand Up @@ -1060,7 +1060,7 @@ def _group_or_org_show(context, data_dict, is_org=False):
schema = logic.schema.default_show_group_schema()
group_dict, errors = lib_plugins.plugin_validate(
group_plugin, context, group_dict, schema,
'organization_show' if is_org else 'group_show')
'organization_show' if is_org else 'group_show', group_dict['type'])
return group_dict


Expand Down
5 changes: 3 additions & 2 deletions ckan/logic/action/update.py
Expand Up @@ -301,7 +301,8 @@ def package_update(context, data_dict):
package_plugin.check_data_dict(data_dict)

data, errors = lib_plugins.plugin_validate(
package_plugin, context, data_dict, schema, 'package_update')
package_plugin, context, data_dict, schema,
'package_update', pkg.type)
log.debug('package_update validate_errs=%r user=%s package=%s data=%r',
errors, context.get('user'),
context.get('package').name if context.get('package') else '',
Expand Down Expand Up @@ -505,7 +506,7 @@ def _group_or_org_update(context, data_dict, is_org=False):

data, errors = lib_plugins.plugin_validate(
group_plugin, context, data_dict, schema,
'organization_update' if is_org else 'group_update')
'organization_update' if is_org else 'group_update', group.type)
log.debug('group_update validate_errs=%r user=%s group=%s data_dict=%r',
errors, context.get('user'),
context.get('group').name if context.get('group') else '',
Expand Down
4 changes: 2 additions & 2 deletions ckan/plugins/interfaces.py
Expand Up @@ -849,7 +849,7 @@ def validate(self, context, data_dict, schema, action, package_type):
:param action: ``'package_show'``, ``'package_create'`` or
``'package_update'``
:type action: string
:param package_type: the package_type of the dataset
:param package_type: the type of the dataset
:type package_type: string
:returns: (data_dict, errors) where data_dict is the possibly-modified
dataset and errors is a dictionary with keys matching data_dict
Expand Down Expand Up @@ -1003,7 +1003,7 @@ def validate(self, context, data_dict, schema, action, group_type):
``'group_update'``, ``'organization_show'``,
``'organization_create'`` or ``'organization_update'``
:type action: string
:param group_type: the group_type of the group
:param group_type: the type of the group
:type group_type: string
:returns: (data_dict, errors) where data_dict is the possibly-modified
group and errors is a dictionary with keys matching data_dict
Expand Down

0 comments on commit 01b53cf

Please sign in to comment.