changeset 2241:f87b673c7d17

plugin invitations: on modify an empty value delete corresponding extra keys, and reserved keys are now ignored.
author Goffi <goffi@goffi.org>
date Fri, 19 May 2017 12:37:54 +0200
parents 4b66f070cfbb
children e5e54ff0b775
files src/plugins/plugin_misc_invitations.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_misc_invitations.py	Fri May 19 12:34:33 2017 +0200
+++ b/src/plugins/plugin_misc_invitations.py	Fri May 19 12:37:54 2017 +0200
@@ -294,6 +294,7 @@
 
         @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 @@
             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