1
0
Fork 0
mirror of https://github.com/Kunsi/pretalx-plugin-broadcast-tools synced 2024-11-21 23:41:02 +00:00

add endpoint to get qr code linking to talk detail page

This commit is contained in:
Franzi 2023-02-28 18:49:29 +01:00
parent 08998e7535
commit e0f47458cd
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 16 additions and 0 deletions

View file

@ -24,6 +24,11 @@ urlpatterns = [
views.BroadcastToolsRoomInfoView.as_view(), views.BroadcastToolsRoomInfoView.as_view(),
name="room_info", name="room_info",
), ),
re_path(
f"^(?P<event>[{SLUG_CHARS}]+)/p/broadcast-tools/public-qr/(?P<talk>[0-9]+).svg$",
views.BroadcastToolsPublicQrCodeSvg.as_view(),
name="public_qr_id",
),
re_path( re_path(
f"^(?P<event>[{SLUG_CHARS}]+)/p/broadcast-tools/schedule.json$", f"^(?P<event>[{SLUG_CHARS}]+)/p/broadcast-tools/schedule.json$",
views.BroadcastToolsScheduleView.as_view(), views.BroadcastToolsScheduleView.as_view(),

View file

@ -90,6 +90,17 @@ class BroadcastToolsFeedbackQrCodeSvg(View):
return HttpResponse(svg_data, content_type="image/svg+xml") return HttpResponse(svg_data, content_type="image/svg+xml")
class BroadcastToolsPublicQrCodeSvg(View):
def get(self, request, *args, **kwargs):
talk = self.request.event.submissions.filter(id=kwargs["talk"]).first()
domain = request.event.custom_domain or settings.SITE_URL
image = qrcode.make(
f"{domain}{talk.urls.public}", image_factory=qrcode.image.svg.SvgImage
)
svg_data = mark_safe(ET.tostring(image.get_image()).decode())
return HttpResponse(svg_data, content_type="image/svg+xml")
class BroadcastToolsScheduleView(EventPermissionRequired, ScheduleMixin, View): class BroadcastToolsScheduleView(EventPermissionRequired, ScheduleMixin, View):
permission_required = "agenda.view_schedule" permission_required = "agenda.view_schedule"