Skip to content

Commit

Permalink
duplicate extras save workardound
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Mar 5, 2014
1 parent 41f6903 commit 4b5d5ab
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ckan/lib/dictization/model_save.py
Expand Up @@ -102,7 +102,18 @@ def package_extras_save(extra_dicts, obj, context):
session = context["session"]

extras_list = obj.extras_list
old_extras = dict((extra.key, extra) for extra in extras_list)

# XXX: clean up duplicate keys
# we've created a mess with our portal_release_date field
old_extras = {}
for extra in extras_list:
if extra.key in old_extras:
if extra.state == 'deleted':
continue
state = 'pending-deleted' if context.get('pending') else 'deleted'
extra.state = state
continue
old_extras[extra.key] = extra

new_extras = {}
for extra_dict in extra_dicts or []:
Expand Down

0 comments on commit 4b5d5ab

Please sign in to comment.