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: (
|
2024-02-14 17:16:02 +01:00
|
|
|
submission.assignee.user.name
|
|
|
|
if hasattr(submission, "assignee")
|
2024-02-13 15:38:04 +01:00
|
|
|
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)
|
2024-02-14 00:54:28 +01:00
|
|
|
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 [
|
2024-02-14 00:54:28 +01:00
|
|
|
{
|
|
|
|
"active": request.resolver_match.view_name
|
|
|
|
== "plugins:pretalx_musicrate:enhanced_list",
|
|
|
|
"icon": "sticky-note-o",
|
2024-11-02 19:34:39 +01:00
|
|
|
"label": _("Sessions, but better"),
|
2024-02-14 00:54:28 +01:00
|
|
|
"url": reverse(
|
|
|
|
"plugins:pretalx_musicrate:enhanced_list",
|
|
|
|
kwargs={"event": request.event.slug},
|
|
|
|
),
|
|
|
|
},
|
2023-12-15 02:48:31 +01:00
|
|
|
{
|
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}
|
|
|
|
),
|
2024-02-14 00:54:28 +01:00
|
|
|
},
|
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 [
|
|
|
|
{
|
2024-11-02 19:34:39 +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
|
|
|
}
|
|
|
|
]
|