From d6b94bc9de66b04360b68acf662d4f6e0659d625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 10 Jul 2018 14:46:10 +0200 Subject: [PATCH] notifications: don't make ack() imply forget() (#25186) --- combo/apps/notifications/models.py | 12 +++--------- tests/test_notification.py | 6 +++--- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/combo/apps/notifications/models.py b/combo/apps/notifications/models.py index af0ec1c..c1dfd95 100644 --- a/combo/apps/notifications/models.py +++ b/combo/apps/notifications/models.py @@ -42,8 +42,7 @@ class NotificationQuerySet(QuerySet): return qs.filter(search_id) def ack(self): - self.filter(end_timestamp__isnull=True).update(acked=True, end_timestamp=now() - timedelta(seconds=5)) - self.filter(end_timestamp__isnull=False).update(acked=True) + self.update(acked=True) def visible(self, user=None, n=None): qs = self @@ -159,13 +158,8 @@ class Notification(models.Model): self.save(update_fields=['end_timestamp', 'acked']) def ack(self): - if self.end_timestamp: - self.acked = True - self.save(update_fields=['acked']) - else: - self.acked = True - self.end_timestamp = now() - timedelta(seconds=5) - self.save(update_fields=['acked', 'end_timestamp']) + self.acked = True + self.save(update_fields=['acked']) @register_cell_class diff --git a/tests/test_notification.py b/tests/test_notification.py index 9593e05..90cda8e 100644 --- a/tests/test_notification.py +++ b/tests/test_notification.py @@ -458,9 +458,9 @@ def test_notification_never_expire(app, freezer, rf, john_doe): Notification.objects.visible(john_doe).ack() - # acking a notification without and end_timestamp, forget it + # acking a notification without and end_timestamp, still visible freezer.move_to(start + timedelta(days=365, seconds=1)) content = cell.render(context) - assert Notification.objects.visible(john_doe).count() == 0 - assert 'notibar' not in content + assert Notification.objects.visible(john_doe).count() == 1 + assert 'notibar' in content assert 'notifoo' not in content -- 2.18.0