Skip to content
Snippets Groups Projects
Verified Commit 83abbb5f authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Move unread notifications query set to a property of the person object

parent e3d82618
No related branches found
No related tags found
1 merge request!447Resolve "Add own menu entry for notifications"
......@@ -245,6 +245,16 @@ class Person(ExtensibleModel):
)
]
@property
def unread_notifications(self) -> QuerySet:
"""Get all unread notifications for this person."""
return self.notifications.filter(read=False)
@property
def unread_notifications_count(self) -> int:
"""Return the count of unread notifications for this person."""
return self.unread_notifications.count()
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
......
......@@ -408,4 +408,4 @@ def queryset_rules_filter(
def unread_notifications_badge(request: HttpRequest) -> int:
"""Generate badge content with the number of unread notifications."""
return request.user.person.notifications.all().filter(read=False).count()
return request.user.person.unread_notifications_count
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment