pretalx-musicrate/pretalx_musicrate/signals.py

39 lines
1.2 KiB
Python
Raw Permalink Normal View History

2023-12-13 23:58:00 +01:00
from django.dispatch import receiver
from django.urls import reverse
2023-12-15 02:48:31 +01:00
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.url_name
== "plugins:pretalx_musicrate:qrcode",
"icon": "star",
"label": _("Collective Rating"),
"url": reverse(
"plugins:pretalx_musicrate:qrcode", kwargs={"event": request.event.slug}
),
}
]
2023-12-13 23:58:00 +01:00
@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",
2023-12-13 23:58:00 +01:00
"url": reverse(
"plugins:pretalx_musicrate:settings",
kwargs={"event": request.event.slug},
),
"active": request.resolver_match.url_name
== "plugins:pretalx_musicrate:settings",
}
]