diff --git a/loko/notifications/locale/en/LC_MESSAGES/django.po b/loko/notifications/locale/en/LC_MESSAGES/django.po index 21c78b3..668bf2b 100644 --- a/loko/notifications/locale/en/LC_MESSAGES/django.po +++ b/loko/notifications/locale/en/LC_MESSAGES/django.po @@ -813,6 +813,11 @@ msgstr "Reset" msgid "Nouveau" msgstr "New" +#: notifications/templates/notifications/inbox.html:255 +#: notifications/templates/notifications/inbox.html:259 +msgid "Marquer comme traitée" +msgstr "Mark as processed" + #: notifications/templates/notifications/inbox.html:255 #: notifications/templates/notifications/inbox.html:259 msgid "Prendre en charge" diff --git a/loko/notifications/locale/fr/LC_MESSAGES/django.po b/loko/notifications/locale/fr/LC_MESSAGES/django.po index 8334095..37ddb19 100644 --- a/loko/notifications/locale/fr/LC_MESSAGES/django.po +++ b/loko/notifications/locale/fr/LC_MESSAGES/django.po @@ -814,6 +814,11 @@ msgstr "Réinitialiser" msgid "Nouveau" msgstr "Nouveau" +#: notifications/templates/notifications/inbox.html:255 +#: notifications/templates/notifications/inbox.html:259 +msgid "Marquer comme traitée" +msgstr "Marquer comme traitée" + #: notifications/templates/notifications/inbox.html:255 #: notifications/templates/notifications/inbox.html:259 msgid "Prendre en charge" diff --git a/loko/notifications/locale/nl/LC_MESSAGES/django.po b/loko/notifications/locale/nl/LC_MESSAGES/django.po index 40a3bb7..d3e8470 100644 --- a/loko/notifications/locale/nl/LC_MESSAGES/django.po +++ b/loko/notifications/locale/nl/LC_MESSAGES/django.po @@ -813,6 +813,11 @@ msgstr "Opnieuw instellen" msgid "Nouveau" msgstr "Nieuw" +#: notifications/templates/notifications/inbox.html:255 +#: notifications/templates/notifications/inbox.html:259 +msgid "Marquer comme traitée" +msgstr "Markeren als verwerkt" + #: notifications/templates/notifications/inbox.html:255 #: notifications/templates/notifications/inbox.html:259 msgid "Prendre en charge" diff --git a/loko/notifications/models.py b/loko/notifications/models.py index 4e63177..3573b6c 100644 --- a/loko/notifications/models.py +++ b/loko/notifications/models.py @@ -193,10 +193,20 @@ class NotificationRecipient(models.Model): def archive(self): if not self.archived_at: - if not self.read_at: + was_unread = self.read_at is None + if was_unread: self.read_at = timezone.now() self.archived_at = timezone.now() self.save(update_fields=['read_at', 'archived_at']) + if was_unread and self.notification.is_single_claim: + now = timezone.now() + NotificationRecipient.objects.filter( + notification=self.notification, + read_at__isnull=True, + ).exclude(pk=self.pk).update( + read_at=now, + archived_at=now, + ) def __str__(self): return f"{self.notification} → {self.user.username}" diff --git a/loko/notifications/services.py b/loko/notifications/services.py index 89fc4e3..ab9b9a1 100644 --- a/loko/notifications/services.py +++ b/loko/notifications/services.py @@ -75,6 +75,7 @@ def notify_user( sender=None, expires_at=None, is_system=False, + is_single_claim=False, ): """ Envoie une notification personnelle à un utilisateur. @@ -91,6 +92,7 @@ def notify_user( sender=sender, expires_at=expires_at, is_system=is_system, + is_single_claim=is_single_claim, ) recipient_obj = NotificationRecipient.objects.create( notification=notification, @@ -117,6 +119,7 @@ def notify_users( sender=None, expires_at=None, is_system=False, + is_single_claim=False, ): """ Envoie une notification à plusieurs utilisateurs (crée un seul objet Notification @@ -134,6 +137,7 @@ def notify_users( sender=sender, expires_at=expires_at, is_system=is_system, + is_single_claim=is_single_claim, ) NotificationRecipient.objects.bulk_create([ NotificationRecipient(notification=notification, user=user) diff --git a/loko/notifications/templates/notifications/inbox.html b/loko/notifications/templates/notifications/inbox.html index c41d34e..6d09352 100644 --- a/loko/notifications/templates/notifications/inbox.html +++ b/loko/notifications/templates/notifications/inbox.html @@ -252,11 +252,11 @@ id="mark-read-{{ item.recipient_id }}-{{ item.recipient_type }}" data-pk="{{ item.recipient_id }}" data-type="{{ item.recipient_type }}" - title="{% if notif.is_single_claim %}{% translate 'Prendre en charge' %}{% else %}{% translate 'Marquer comme lu' %}{% endif %}"> + title="{% if notif.is_single_claim %}{% translate 'Marquer comme traitée' %}{% else %}{% translate 'Marquer comme lu' %}{% endif %}">