From b3b3ef825a27accf05e4ad2cf91612ff0860faa0 Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Wed, 27 Nov 2024 13:59:49 +0100 Subject: [PATCH] fix comments --- lemarche/users/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lemarche/users/models.py b/lemarche/users/models.py index 0213b8658..7f0e64e6b 100644 --- a/lemarche/users/models.py +++ b/lemarche/users/models.py @@ -411,12 +411,11 @@ def tender_siae_unread_count(self): @receiver(pre_save, sender=User) -def update_old_api_keys(sender, instance, **kwargs): +def update_api_key_last_update(sender, instance, **kwargs): """ - Before saving a user, add the old value of `api_key` to `old_api_keys` - if `api_key` has been modified. + Before saving a user, add the to `api_key_last_updated` """ - if instance.pk: # Check if the user already exists (not a new creation) + if instance.pk: try: old_instance = sender.objects.get(pk=instance.pk) if old_instance.api_key != instance.api_key: @@ -424,6 +423,8 @@ def update_old_api_keys(sender, instance, **kwargs): instance.api_key_last_updated = timezone.now() except sender.DoesNotExist: instance.api_key_last_updated = timezone.now() + else: + instance.api_key_last_updated = timezone.now() @receiver(post_save, sender=User)