Skip to content

Commit

Permalink
[#2845] Allow passing empty lists to group_update
Browse files Browse the repository at this point in the history
If, for example, a group dict with a 'packages' key with an empty list
as the value is passed to group_update, then set the group's packages to
an empty list (i.e. remove any packages from the group), even if
'allow_partial_update': True was specified in the context (previously
such an empty list would be ignored and the group's packages would not
change). Also applies to other group fields e.g. tags, users, groups, etc.
  • Loading branch information
Sean Hammond committed Aug 18, 2012
1 parent e3a6793 commit 6f7fa8b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ckan/lib/dictization/model_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,13 @@ def group_member_save(context, group_dict, member_table_name):
model = context["model"]
session = context["session"]
group = context['group']
entity_list = group_dict.get(member_table_name, [])
entity_list = group_dict.get(member_table_name, None)

if entity_list == [] and context.get('allow_partial_update', False):
return {'added': [], 'removed': []}
if entity_list is None:
if context.get('allow_partial_update', False):
return {'added': [], 'removed': []}
else:
entity_list = []

entities = {}
Member = model.Member
Expand Down

0 comments on commit 6f7fa8b

Please sign in to comment.