feat: Make notification counter display actual number of notifications

This commit is contained in:
moanos [he/him] 2024-08-03 08:24:40 +02:00
parent dda421e557
commit 79406882ea
2 changed files with 4 additions and 1 deletions

View File

@ -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')

View File

@ -23,7 +23,7 @@
<a href="{{ user.get_notifications_url }}">
<i class="fa fa-bell" aria-hidden="true"></i>
</a>
<span class="button__badge">4</span>
<span class="button__badge">{{ user.get_num_unread_notifications }}</span>
</div>