from .models import Notification


def notifications(request):
    if request.user.is_authenticated:
        unread_count = Notification.objects.filter(user=request.user, unread=True).count()
        latest_notifications = Notification.objects.filter(user=request.user).order_by("-created_at")[:5]
        return {
            "notification_unread_count": unread_count,
            "notification_menu_items": latest_notifications,
        }
    return {}
