loko/streetup/notifications/context_processors.py
2026-07-22 14:48:40 +02:00

13 lines
478 B
Python

def unread_notifications_count(request):
"""
Injecte le nombre de notifications non lues dans tous les templates.
Disponible via la variable {{ unread_notifications_count }}.
"""
if not request.user.is_authenticated:
return {'unread_notifications_count': 0}
try:
from .services import get_unread_count
count = get_unread_count(request.user)
except Exception:
count = 0
return {'unread_notifications_count': count}