pretalx-musicrate/pretalx_musicrate/signals.py

68 lines
2.2 KiB
Python
Raw 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 _
2024-02-13 15:32:23 +01:00
from pretalx.mail.placeholders import SimpleFunctionalMailTextPlaceholder
from pretalx.mail.signals import register_mail_placeholders
2023-12-15 02:48:31 +01:00
from pretalx.orga.signals import nav_event, nav_event_settings
2024-02-13 15:32:23 +01:00
@receiver(register_mail_placeholders)
def pretalx_musicrate_placeholders(sender, **kwargs):
return [
SimpleFunctionalMailTextPlaceholder(
"assignee",
["submission"],
2024-02-13 15:38:04 +01:00
lambda submission: (
assignee.user.name
if (assignee := submission.assignee) is not None
else "Günther"
),
2024-02-13 15:32:23 +01:00
"Günther",
_("The name of the submission's assignee"),
)
]
2023-12-15 02:48:31 +01:00
@receiver(nav_event)
def pretalx_musicrate_nav_event(sender, request, **kwargs):
2023-12-15 02:48:31 +01:00
if not request.user.has_perm("orga.view_submissions", request.event):
return []
return [
{
"active": request.resolver_match.view_name
== "plugins:pretalx_musicrate:enhanced_list",
"icon": "sticky-note-o",
"label": _("Proposals, but better"),
"url": reverse(
"plugins:pretalx_musicrate:enhanced_list",
kwargs={"event": request.event.slug},
),
},
2023-12-15 02:48:31 +01:00
{
"active": request.resolver_match.view_name
2023-12-15 02:48:31 +01:00
== "plugins:pretalx_musicrate:qrcode",
"icon": "star",
"label": _("Collective Rating"),
"url": reverse(
"plugins:pretalx_musicrate:qrcode", kwargs={"event": request.event.slug}
),
},
2023-12-15 02:48:31 +01:00
]
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(
2023-12-18 01:15:50 +01:00
"plugins:pretalx_musicrate:settings.musicrate",
2023-12-13 23:58:00 +01:00
kwargs={"event": request.event.slug},
),
"active": request.resolver_match.view_name
2023-12-18 01:15:50 +01:00
== "plugins:pretalx_musicrate:settings.musicrate",
2023-12-13 23:58:00 +01:00
}
]