plugin invitations: on modify an empty value delete corresponding extra keys, and reserved keys are now ignored.

This commit is contained in:
Goffi 2017-05-19 12:37:54 +02:00
commit 97c3333418

View file

@ -294,6 +294,7 @@ class InvitationsPlugin(object):
@param id_(unicode): UUID linked to an invitation
@param new_extra(dict[unicode, unicode]): data to update
empty values will be deleted if replace is True
@param replace(bool): if True replace the data
else update them
@raise KeyError: there is not invitation with this id_
@ -310,7 +311,16 @@ class InvitationsPlugin(object):
else:
new_data = current_data
for k,v in new_extra.iteritems():
new_data[k] = v
if k in EXTRA_RESERVED:
log.warning(_(u"Skipping reserved key {key}".format(k)))
continue
if v:
new_data[k] = v
else:
try:
del new_data[k]
except KeyError:
pass
self.invitations[id_] = new_data