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"],
|
|
|
|
lambda submission: assignee.user.name
|
|
|
|
if (assignee := submission.assignee) is not None
|
|
|
|
else "Günther",
|
|
|
|
"Günther",
|
|
|
|
_("The name of the submission's assignee"),
|
|
|
|
)
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2023-12-15 02:48:31 +01:00
|
|
|
@receiver(nav_event)
|
|
|
|
def pretalx_musicrate_qrcode(sender, request, **kwargs):
|
|
|
|
if not request.user.has_perm("orga.view_submissions", request.event):
|
|
|
|
return []
|
|
|
|
return [
|
|
|
|
{
|
2023-12-18 01:11:53 +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-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 [
|
|
|
|
{
|
2023-12-14 19:36:50 +01:00
|
|
|
"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},
|
|
|
|
),
|
2023-12-18 01:11:53 +01:00
|
|
|
"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
|
|
|
}
|
|
|
|
]
|