diff --git a/pretalx_musicrate/signals.py b/pretalx_musicrate/signals.py
index 189b14f..1df731c 100644
--- a/pretalx_musicrate/signals.py
+++ b/pretalx_musicrate/signals.py
@@ -1,6 +1,24 @@
from django.dispatch import receiver
from django.urls import reverse
-from pretalx.orga.signals import nav_event_settings
+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}
+ ),
+ }
+ ]
@receiver(nav_event_settings)
diff --git a/pretalx_musicrate/templates/pretalx_musicrate/qrcode.html b/pretalx_musicrate/templates/pretalx_musicrate/qrcode.html
new file mode 100644
index 0000000..7444a2f
--- /dev/null
+++ b/pretalx_musicrate/templates/pretalx_musicrate/qrcode.html
@@ -0,0 +1,9 @@
+{% extends "cfp/event/base.html" %}
+{% load qrcode %}
+
+{% block content %}
+
+ {% qrcode contents %}
+ {{ contents | urlize }}
+
+{% endblock %}
diff --git a/pretalx_musicrate/templatetags/__init__.py b/pretalx_musicrate/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pretalx_musicrate/templatetags/qrcode.py b/pretalx_musicrate/templatetags/qrcode.py
new file mode 100644
index 0000000..8daddf9
--- /dev/null
+++ b/pretalx_musicrate/templatetags/qrcode.py
@@ -0,0 +1,15 @@
+from django import template
+from django.utils.safestring import mark_safe
+from qrcode import make
+from qrcode.image.svg import SvgPathFillImage
+
+register = template.Library()
+
+
+@register.simple_tag
+def qrcode(data):
+ return mark_safe(
+ make(data, box_size=20, image_factory=SvgPathFillImage)
+ .to_string()
+ .decode("utf-8")
+ )
diff --git a/pretalx_musicrate/urls.py b/pretalx_musicrate/urls.py
index c6b9322..3a9bf7e 100644
--- a/pretalx_musicrate/urls.py
+++ b/pretalx_musicrate/urls.py
@@ -1,12 +1,19 @@
-from django.urls import re_path
-from pretalx.event.models.event import SLUG_REGEX
+from django.urls import include, path
-from .views import MusicrateSettingsView
+from .views import MusicrateSettingsView, QRCodeView
urlpatterns = [
- re_path(
- rf"^orga/event/(?P{SLUG_REGEX})/settings/p/pretalx_musicrate/$",
+ path(
+ "orga/event//settings/p/pretalx_musicrate/",
MusicrateSettingsView.as_view(),
name="settings",
),
+ path(
+ "/p/pretalx_musicrate/",
+ include(
+ [
+ path("", QRCodeView.as_view(), name="qrcode"),
+ ]
+ ),
+ ),
]
diff --git a/pretalx_musicrate/views.py b/pretalx_musicrate/views.py
index d43e583..2670c60 100644
--- a/pretalx_musicrate/views.py
+++ b/pretalx_musicrate/views.py
@@ -1,12 +1,14 @@
from django.contrib import messages
+from django.urls import reverse
from django.utils.translation import gettext_lazy as _
-from django.views.generic import FormView
-from pretalx.common.mixins.views import PermissionRequired
+from django.views.generic import FormView, TemplateView
+from pretalx.common.mixins.views import EventPermissionRequired
+
from .forms import MusicrateSettingsForm
-class MusicrateSettingsView(PermissionRequired, FormView):
+class MusicrateSettingsView(EventPermissionRequired, FormView):
permission_required = "orga.change_settings"
template_name = "pretalx_musicrate/settings.html"
form_class = MusicrateSettingsForm
@@ -14,9 +16,6 @@ class MusicrateSettingsView(PermissionRequired, FormView):
def get_success_url(self):
return self.request.path
- def get_object(self):
- return self.request.event
-
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
kwargs["event"] = self.request.event
@@ -28,3 +27,21 @@ class MusicrateSettingsView(PermissionRequired, FormView):
self.request, _("The pretalx-musicrate settings were updated.")
)
return super().form_valid(form)
+
+
+class QRCodeView(EventPermissionRequired, TemplateView):
+ permission_required = "orga.view_submissions"
+ template_name = "pretalx_musicrate/qrcode.html"
+
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ context["contents"] = self.request.build_absolute_uri(
+ reverse(
+ "plugins:pretalx_musicrate:join",
+ kwargs={
+ "event": self.request.event.slug,
+ "token": self.request.event.pretalx_musicrate_settings.join_token,
+ },
+ )
+ )
+ return context
diff --git a/pyproject.toml b/pyproject.toml
index 17d637f..8294e67 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -16,6 +16,7 @@ dependencies = [
"Django",
"django-i18nfield",
"pretalx",
+ "qrcode",
]
[project.urls]