From 18f82d1df3fc91c20835dc6dd73b26019b41ccf1 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 20 Nov 2021 17:46:05 +0100 Subject: [PATCH] add some settings for 'currently no talk running', add configurable info line --- pretalx_lower_thirds/forms.py | 17 +++++++++ pretalx_lower_thirds/signals.py | 19 +++++++++- .../static/pretalx_lower_thirds/frontend.css | 5 +++ .../static/pretalx_lower_thirds/update.js | 4 +- .../pretalx_lower_thirds/lower_thirds.html | 1 + .../templates/pretalx_lower_thirds/orga.html | 37 +++++++++++++++++++ pretalx_lower_thirds/urls.py | 6 +++ pretalx_lower_thirds/views.py | 31 +++++++++++++++- 8 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 pretalx_lower_thirds/forms.py create mode 100644 pretalx_lower_thirds/templates/pretalx_lower_thirds/orga.html diff --git a/pretalx_lower_thirds/forms.py b/pretalx_lower_thirds/forms.py new file mode 100644 index 0000000..b8eb5da --- /dev/null +++ b/pretalx_lower_thirds/forms.py @@ -0,0 +1,17 @@ +from django import forms +from django.utils.translation import gettext_lazy as _ +from hierarkey.forms import HierarkeyForm + + +class LowerThirdsSettingsForm(HierarkeyForm): + lower_thirds_no_talk_info = forms.CharField( + help_text='Will be shown as talk title if there\'s currently no talk running.', + initial = 'Sorry, there\'s currently no talk running', + label='"no talk running" information', + required=True, + ) + lower_thirds_info_string = forms.CharField( + initial='', + label='info line', + required=False, + ) diff --git a/pretalx_lower_thirds/signals.py b/pretalx_lower_thirds/signals.py index a025794..ed713a7 100644 --- a/pretalx_lower_thirds/signals.py +++ b/pretalx_lower_thirds/signals.py @@ -1 +1,18 @@ -# Register your receivers here +from django.dispatch import receiver +from django.urls import resolve, reverse +from django.utils.translation import ugettext_lazy as _ +from pretalx.orga.signals import nav_event_settings + + +@receiver(nav_event_settings) +def navbar_info(sender, request, **kwargs): + url = resolve(request.path_info) + if not request.user.has_perm('orga.change_settings', request.event): + return [] + return [{ + 'label': _('lower thirds'), + 'url': reverse('plugins:pretalx_lower_thirds:orga', kwargs={ + 'event': request.event.slug, + }), + 'active': url.namespace == 'plugins:pretalx_lower_thirds' and url.url_name == 'orga', + }] diff --git a/pretalx_lower_thirds/static/pretalx_lower_thirds/frontend.css b/pretalx_lower_thirds/static/pretalx_lower_thirds/frontend.css index 7b49b82..074f1dd 100644 --- a/pretalx_lower_thirds/static/pretalx_lower_thirds/frontend.css +++ b/pretalx_lower_thirds/static/pretalx_lower_thirds/frontend.css @@ -28,3 +28,8 @@ #speaker { font-size: 20px; } + +#info_line { + font-size: 16px; + text-align: right; +} diff --git a/pretalx_lower_thirds/static/pretalx_lower_thirds/update.js b/pretalx_lower_thirds/static/pretalx_lower_thirds/update.js index ee25ec1..a0b401e 100644 --- a/pretalx_lower_thirds/static/pretalx_lower_thirds/update.js +++ b/pretalx_lower_thirds/static/pretalx_lower_thirds/update.js @@ -49,9 +49,11 @@ function update_lower_third() { if (current_talk) { $('#title').text(current_talk['title']); $('#speaker').text(current_talk['persons'].join(', ')); + $('#info_line').text(current_talk['infoline']); } else { - $('#title').text('Currently no talk'); + $('#title').text(schedule['conference']['no_talk']); $('#speaker').text(''); + $('#info_line').text(''); } if (current_talk && current_talk['track']) { diff --git a/pretalx_lower_thirds/templates/pretalx_lower_thirds/lower_thirds.html b/pretalx_lower_thirds/templates/pretalx_lower_thirds/lower_thirds.html index 0efedaa..ff715ca 100644 --- a/pretalx_lower_thirds/templates/pretalx_lower_thirds/lower_thirds.html +++ b/pretalx_lower_thirds/templates/pretalx_lower_thirds/lower_thirds.html @@ -20,6 +20,7 @@

Loading ...

Content should appear soon. If not, please verify you have Javascript enabled.

+

diff --git a/pretalx_lower_thirds/templates/pretalx_lower_thirds/orga.html b/pretalx_lower_thirds/templates/pretalx_lower_thirds/orga.html new file mode 100644 index 0000000..e09db12 --- /dev/null +++ b/pretalx_lower_thirds/templates/pretalx_lower_thirds/orga.html @@ -0,0 +1,37 @@ +{% extends "orga/base.html" %} +{% load bootstrap4 %} +{% load i18n %} + +{% block content %} +

{% trans "Set up lower thirds" %}

+
+ {% csrf_token %} + {% bootstrap_form form layout='event' %} +

+ The info line will be shown on the bottom right side of your + lower third. If you set it to an empty string, it will automatically + hide itself. +

+

+ pretalx will automatically replace some placeholders in your info + string. + Use {CODE} to embed the talk code (MUX9U3 + for example). You could use this to directly link to the talk + feedback page. + Use {EVENT_SLUG} to get the event slug. + Use {TALK_SLUG} to get the talk slug. +

+
+ + + + +
+
+{% endblock %} diff --git a/pretalx_lower_thirds/urls.py b/pretalx_lower_thirds/urls.py index bb0568c..c672a10 100644 --- a/pretalx_lower_thirds/urls.py +++ b/pretalx_lower_thirds/urls.py @@ -15,4 +15,10 @@ urlpatterns = [ views.ScheduleView.as_view(), name="schedule", ), + + re_path( + f"^orga/event/(?P[{SLUG_CHARS}]+)/p/lower-thirds/$", + views.LowerThirdsOrgaView.as_view(), + name="orga", + ), ] diff --git a/pretalx_lower_thirds/views.py b/pretalx_lower_thirds/views.py index d83c273..cc701bd 100644 --- a/pretalx_lower_thirds/views.py +++ b/pretalx_lower_thirds/views.py @@ -11,19 +11,42 @@ from django.urls import reverse from django.utils.functional import cached_property from django.utils.timezone import now from django.utils.translation import gettext_lazy as _ +from django.views.generic import FormView from django.views.generic.base import TemplateView from django_context_decorator import context from pretalx.agenda.views.schedule import ScheduleMixin -from pretalx.common.mixins.views import EventPermissionRequired +from pretalx.common.mixins.views import EventPermissionRequired, PermissionRequired from pretalx.common.signals import register_data_exporters from pretalx.schedule.exporters import ScheduleData +from .forms import LowerThirdsSettingsForm + class LowerThirdsView(TemplateView): template_name = "pretalx_lower_thirds/lower_thirds.html" +class LowerThirdsOrgaView(PermissionRequired, FormView): + form_class = LowerThirdsSettingsForm + permission_required = 'orga.change_settings' + template_name = "pretalx_lower_thirds/orga.html" + + def get_success_url(self): + return self.request.path + + def form_valid(self, form): + form.save() + return super().form_valid(form) + + def get_object(self): + return self.request.event + + def get_form_kwargs(self): + kwargs = super().get_form_kwargs() + return {'obj': self.request.event, 'attribute_name': 'settings', **kwargs} + + class ScheduleView(EventPermissionRequired, ScheduleMixin, TemplateView): permission_required = "agenda.view_schedule" @@ -38,6 +61,7 @@ class ScheduleView(EventPermissionRequired, ScheduleMixin, TemplateView): "conference": { "slug": schedule.event.slug, "name": str(schedule.event.name), + "no_talk": str(schedule.event.settings.lower_thirds_no_talk_info), }, "rooms": sorted({ str(room["name"]) @@ -59,6 +83,11 @@ class ScheduleView(EventPermissionRequired, ScheduleMixin, TemplateView): "name": str(talk.submission.track.name), } if talk.submission.track else None, "room": str(room["name"]), + "infoline": str(schedule.event.settings.lower_thirds_info_string).format( + EVENT_SLUG=str(schedule.event.slug), + TALK_SLUG=talk.frab_slug, + CODE=talk.submission.code, + ), } for day in schedule.data for room in day["rooms"]