35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from django.dispatch import receiver
|
|
from django.shortcuts import reverse
|
|
from shiftregister.core.signals import populate_nav
|
|
from .models import IncomingMessage
|
|
|
|
|
|
@receiver(populate_nav, dispatch_uid="populate_team_nav")
|
|
def populate_team_nav(sender, **kwargs):
|
|
request = sender
|
|
nav_items = []
|
|
|
|
if request.user.is_authenticated:
|
|
nav_items.append(
|
|
{"link": reverse("team:shift_overview"), "text": "Schichtübersicht"}
|
|
)
|
|
nav_items.append(
|
|
{"link": reverse("team:shift_free"), "text": "Freie Schichten"}
|
|
)
|
|
nav_items.append({"link": reverse("team:shift_all"), "text": "Alle Schichten"})
|
|
nav_items.append(
|
|
{"link": reverse("team:bulk_message"), "text": "Massen-Nachricht"}
|
|
)
|
|
|
|
num_unread = IncomingMessage.objects.filter(read=False).count()
|
|
nav_items.append(
|
|
{
|
|
"link": reverse("team:incoming_messages"),
|
|
"text": "Eingehende Nachrichten" + f" ({num_unread})"
|
|
if num_unread
|
|
else "",
|
|
}
|
|
)
|
|
|
|
return nav_items
|