Skip to content

Commit

Permalink
Updated edit in controller to reindex packages when name changed
Browse files Browse the repository at this point in the history
(cherry picked from commit dbe25d8)
  • Loading branch information
rossjones authored and icmurray committed Oct 4, 2012
1 parent 4b94642 commit bd6a674
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ckan/controllers/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,28 @@ def _save_new(self, context, group_type=None):
error_summary = e.error_summary
return self.new(data_dict, errors, error_summary)

def _force_reindex(self,grp):
""" When the group name has changed, we need to force a reindex
of the datasets within the group, otherwise they will stop
appearing on the read page for the group (as they're connected via
the group name)"""
from ckan.lib.search import rebuild

group = model.Group.get(grp['name'])
for dataset in group.active_packages().all():
rebuild( dataset.name )

def _save_edit(self, id, context):
try:
data_dict = clean_dict(unflatten(
tuplize_dict(parse_params(request.params))))
context['message'] = data_dict.get('log_message', '')
data_dict['id'] = id
group = get_action('group_update')(context, data_dict)

if id != group["name"]:
self._force_reindex(group)

h.redirect_to('%s_read' % str(group['type']), id=group['name'])
except NotAuthorized:
abort(401, _('Unauthorized to read group %s') % id)
Expand Down

0 comments on commit bd6a674

Please sign in to comment.