diff --git a/ckan/lib/dictization/model_save.py b/ckan/lib/dictization/model_save.py index 540bf645c6e..4a3ff1015d8 100644 --- a/ckan/lib/dictization/model_save.py +++ b/ckan/lib/dictization/model_save.py @@ -381,14 +381,13 @@ def group_member_save(context, group_dict, member_table_name): return processed -def group_dict_save(group_dict, context): +def group_dict_save(group_dict, context, prevent_packages_update=False): from ckan.lib.search import rebuild model = context["model"] session = context["session"] group = context.get("group") allow_partial_update = context.get("allow_partial_update", False) - prevent_packages_update = context.get("prevent_packages_update", False) Group = model.Group if group: @@ -418,14 +417,6 @@ def group_dict_save(group_dict, context): 'Groups: %r Tags: %r', pkgs_edited, group_users_changed, group_groups_changed, group_tags_changed) - # We will get a list of packages that we have either added or - # removed from the group, and trigger a re-index. - package_ids = pkgs_edited['removed'] - package_ids.extend( pkgs_edited['added'] ) - if package_ids: - session.commit() - map( rebuild, package_ids ) - extras = group_extras_save(group_dict.get("extras", {}), context) if extras or not allow_partial_update: old_extras = set(group.extras.keys()) @@ -435,6 +426,14 @@ def group_dict_save(group_dict, context): for key in new_extras: group.extras[key] = extras[key] + # We will get a list of packages that we have either added or + # removed from the group, and trigger a re-index. + package_ids = pkgs_edited['removed'] + package_ids.extend( pkgs_edited['added'] ) + if package_ids: + session.commit() + map( rebuild, package_ids ) + return group diff --git a/ckan/logic/action/update.py b/ckan/logic/action/update.py index 0cd0332efde..3cbd2abbe8d 100644 --- a/ckan/logic/action/update.py +++ b/ckan/logic/action/update.py @@ -523,14 +523,8 @@ def _group_or_org_update(context, data_dict, is_org=False): else: rev.message = _(u'REST API: Update object %s') % data.get("name") - # when editing an org we do not want to update the packages if using the - # new templates. - if ((not is_org) - and not converters.asbool( - config.get('ckan.legacy_templates', False)) - and 'api_version' not in context): - context['prevent_packages_update'] = True - group = model_save.group_dict_save(data, context) + group = model_save.group_dict_save(data, context, + prevent_packages_update=is_org) if is_org: plugin_type = plugins.IOrganizationController @@ -617,6 +611,9 @@ def organization_update(context, data_dict): :param id: the name or id of the organization to update :type id: string + :param packages: ignored. use + :py:func:`~ckan.logic.action.update.package_owner_org_update` + to change package ownership :returns: the updated organization :rtype: dictionary