Mercurial > libervia-backend
diff src/plugins/plugin_misc_invitations.py @ 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 | ebc0c1701811 |
children | ba613d32ca60 |
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