diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8cb401a23aa2ad0a9449226d30e1ac11d990e830..6be885dbead43b7d687e21bec5678dbd52348a16 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -23,6 +23,7 @@ Fixed * Added locales-all to base image and note to docs * The icons in the account menu were still the old ones. * Due to a merge error, the once removed account menu in the sidenav appeared again. +* Scheduled notifications were shown on dashboard before time. Changed ~~~~~~~ diff --git a/aleksis/core/models.py b/aleksis/core/models.py index 7c555b409c0aac4a8631df21e6aabadbadd26242..754c4fea9c076adfeb24f038b99d09960117c17b 100644 --- a/aleksis/core/models.py +++ b/aleksis/core/models.py @@ -309,7 +309,7 @@ class Person(ExtensibleModel): @property def unread_notifications(self) -> QuerySet: """Get all unread notifications for this person.""" - return self.notifications.filter(read=False) + return self.notifications.filter(read=False, send_at__lte=timezone.now()) @property def unread_notifications_count(self) -> int: diff --git a/aleksis/core/views.py b/aleksis/core/views.py index 32e83c3746630ddf96e5c179180dbfb2face50d2..cb5a9169c5a9bb0048a998f289ee9a44432d06e9 100644 --- a/aleksis/core/views.py +++ b/aleksis/core/views.py @@ -219,7 +219,9 @@ def index(request: HttpRequest) -> HttpResponse: notifications = person.notifications.filter(send_at__lte=timezone.now()).order_by("-created")[ :5 ] - unread_notifications = person.notifications.all().filter(read=False).order_by("-created") + unread_notifications = person.notifications.filter( + send_at__lte=timezone.now(), read=False + ).order_by("-created") context["activities"] = activities context["notifications"] = notifications