2025-09-12 13:04:04 +02:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# unread_notifications_count()
|
|
|
|
# ---------------------------------------------------------------------------
|
2025-09-10 13:44:03 +02:00
|
|
|
def unread_notifications_count(request):
|
2025-09-12 13:04:04 +02:00
|
|
|
"""
|
|
|
|
Context processor:
|
|
|
|
Returns the number of unread notifications for the current user.
|
|
|
|
"""
|
2025-09-10 13:44:03 +02:00
|
|
|
if not request.user.is_authenticated:
|
|
|
|
return {"notifications_unread_count": 0}
|
2025-09-12 13:04:04 +02:00
|
|
|
|
2025-09-10 13:44:03 +02:00
|
|
|
from .models import Notification
|
2025-09-12 13:04:04 +02:00
|
|
|
count = Notification.objects.filter(user=request.user, read=False).count()
|
|
|
|
return {"notifications_unread_count": count}
|