pretalx-musicrate/pretalx_musicrate/signals.py

39 lines
1.2 KiB
Python

from django.dispatch import receiver
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from pretalx.orga.signals import nav_event, nav_event_settings
@receiver(nav_event)
def pretalx_musicrate_qrcode(sender, request, **kwargs):
if not request.user.has_perm("orga.view_submissions", request.event):
return []
return [
{
"active": request.resolver_match.view_name
== "plugins:pretalx_musicrate:qrcode",
"icon": "star",
"label": _("Collective Rating"),
"url": reverse(
"plugins:pretalx_musicrate:qrcode", kwargs={"event": request.event.slug}
),
}
]
@receiver(nav_event_settings)
def pretalx_musicrate_settings(sender, request, **kwargs):
if not request.user.has_perm("orga.change_settings", request.event):
return []
return [
{
"label": "pretalx-musicrate",
"url": reverse(
"plugins:pretalx_musicrate:settings",
kwargs={"event": request.event.slug},
),
"active": request.resolver_match.view_name
== "plugins:pretalx_musicrate:settings",
}
]