From 79406882ea26d08ce1f12ac799dca9edb9a65fc7 Mon Sep 17 00:00:00 2001 From: moanos Date: Sat, 3 Aug 2024 08:24:40 +0200 Subject: [PATCH] feat: Make notification counter display actual number of notifications --- src/fellchensammlung/models.py | 3 +++ src/fellchensammlung/templates/fellchensammlung/header.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index f67f7f8..36991b3 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -71,6 +71,9 @@ class User(AbstractUser): def get_notifications_url(self): return self.get_absolute_url() + def get_num_unread_notifications(self): + return BaseNotification.objects.filter(user=self,read=False).count() + class Image(models.Model): image = models.ImageField(upload_to='images') diff --git a/src/fellchensammlung/templates/fellchensammlung/header.html b/src/fellchensammlung/templates/fellchensammlung/header.html index 1149101..23a38ac 100644 --- a/src/fellchensammlung/templates/fellchensammlung/header.html +++ b/src/fellchensammlung/templates/fellchensammlung/header.html @@ -23,7 +23,7 @@ - 4 + {{ user.get_num_unread_notifications }}