diff --git a/amadeus/context_processors.py b/amadeus/context_processors.py
index b0e6349..585e13e 100644
--- a/amadeus/context_processors.py
+++ b/amadeus/context_processors.py
@@ -15,7 +15,10 @@ def theme(request):
def notifies(request):
context = {}
- notifications = Notification.objects.filter(creation_date = datetime.now()).count()
+ notifications = 0
+
+ if request.user.is_authenticated:
+ notifications = Notification.objects.filter(creation_date = datetime.now(), viewed = False, user = request.user).count()
context['notifications_count'] = notifications
diff --git a/categories/templatetags/category_counters.py b/categories/templatetags/category_counters.py
index 44e516d..a1fd1c0 100644
--- a/categories/templatetags/category_counters.py
+++ b/categories/templatetags/category_counters.py
@@ -6,9 +6,9 @@ from notifications.models import Notification
register = template.Library()
@register.inclusion_tag('subjects/badge.html')
-def notifies_cat_number(category):
+def notifies_cat_number(category, user):
context = {}
- context['number'] = Notification.objects.filter(task__resource__topic__subject__category = category, creation_date = datetime.now()).count()
+ context['number'] = Notification.objects.filter(task__resource__topic__subject__category = category, creation_date = datetime.now(), viewed = False, user = user).count()
return context
\ No newline at end of file
diff --git a/subjects/templates/subjects/list.html b/subjects/templates/subjects/list.html
index f147820..cdf0135 100644
--- a/subjects/templates/subjects/list.html
+++ b/subjects/templates/subjects/list.html
@@ -83,7 +83,7 @@
- {% notifies_cat_number category %}
+ {% notifies_cat_number category request.user %}
@@ -147,10 +147,14 @@
{% trans 'Remove' %}
{% endif %}
-
-
-
-
+
+
+
+
+ {% notifies_cat_number category request.user %}
+
+
+
diff --git a/subjects/templates/subjects/subject_card.html b/subjects/templates/subjects/subject_card.html
index 9413f24..b1a2964 100644
--- a/subjects/templates/subjects/subject_card.html
+++ b/subjects/templates/subjects/subject_card.html
@@ -39,7 +39,7 @@
- {% notifies_number subject %}
+ {% notifies_number subject request.user %}
diff --git a/subjects/templates/subjects/view.html b/subjects/templates/subjects/view.html
index ec7b0d0..f9d077f 100644
--- a/subjects/templates/subjects/view.html
+++ b/subjects/templates/subjects/view.html
@@ -1,6 +1,6 @@
{% extends 'categories/home.html' %}
-{% load static i18n pagination permissions_tags %}
+{% load static i18n pagination permissions_tags subject_counter %}
{% load django_bootstrap_breadcrumbs %}
{% block javascript%}
@@ -55,10 +55,13 @@
{% trans 'Remove' %}
{% endif %}
-
-
-
-
+
+
+
+ {% notifies_number subject request.user %}
+
+
+
diff --git a/subjects/templatetags/subject_counter.py b/subjects/templatetags/subject_counter.py
index 0b9ac1d..8f07e5b 100644
--- a/subjects/templatetags/subject_counter.py
+++ b/subjects/templatetags/subject_counter.py
@@ -20,10 +20,10 @@ def subject_count(category, user):
return total
@register.inclusion_tag('subjects/badge.html')
-def notifies_number(subject):
+def notifies_number(subject, user):
context = {}
- context['number'] = Notification.objects.filter(task__resource__topic__subject = subject, creation_date = datetime.datetime.now()).count()
+ context['number'] = Notification.objects.filter(task__resource__topic__subject = subject, creation_date = datetime.datetime.now(), viewed = False, user = user).count()
return context
--
libgit2 0.21.2