saml: use get_or_create() in save_key_values (fixes #6883)
With a simple Model.save() the second save in case of replay fails because the created is updated to the NULL value. It seem that initialization of DateTime field is ignored when Django detects that a save is an UPDATE and not an INSERT.
This commit is contained in:
parent
5d6723ad00
commit
6491033c80
|
@ -819,7 +819,11 @@ class KeyValue(models.Model):
|
|||
verbose_name_plural = _("key value associations")
|
||||
|
||||
def save_key_values(key, *values):
|
||||
KeyValue(key = key, value = values).save()
|
||||
# never update an existing key, key are nonces
|
||||
kv, created = KeyValue.objects.get_or_create(key=key, defaults={'value': values})
|
||||
if not created:
|
||||
kv.value = values
|
||||
kv.save()
|
||||
|
||||
def get_and_delete_key_values(key):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue