add some settings for 'currently no talk running', add configurable info line

This commit is contained in:
Franzi 2021-11-20 17:46:05 +01:00
parent a4ad26ac0b
commit 18f82d1df3
Signed by: kunsi
GPG Key ID: 12E3D2136B818350
8 changed files with 117 additions and 3 deletions

View File

@ -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,
)

View File

@ -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',
}]

View File

@ -28,3 +28,8 @@
#speaker {
font-size: 20px;
}
#info_line {
font-size: 16px;
text-align: right;
}

View File

@ -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']) {

View File

@ -20,6 +20,7 @@
<div id="box">
<p id="title">Loading ...</p>
<p id="speaker">Content should appear soon. If not, please verify you have Javascript enabled.</p>
<p id="info_line"></p>
</div>
</body>
</html>

View File

@ -0,0 +1,37 @@
{% extends "orga/base.html" %}
{% load bootstrap4 %}
{% load i18n %}
{% block content %}
<h2>{% trans "Set up lower thirds" %}</h2>
<form method="post">
{% csrf_token %}
{% bootstrap_form form layout='event' %}
<p>
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.
</p>
<p>
pretalx will automatically replace some placeholders in your info
string.
Use <code>{CODE}</code> to embed the talk code (<code>MUX9U3</code>
for example). You could use this to directly link to the talk
feedback page.
Use <code>{EVENT_SLUG}</code> to get the event slug.
Use <code>{TALK_SLUG}</code> to get the talk slug.
</p>
<div class="submit-group panel">
<span></span>
<span class="d-flex flex-row-reverse">
<button
type="submit" class="btn btn-success btn-lg"
name="action" value="save"
>
<i class="fa fa-check"></i>
{% trans "Save" %}
</button>
</span>
</div>
</form>
{% endblock %}

View File

@ -15,4 +15,10 @@ urlpatterns = [
views.ScheduleView.as_view(),
name="schedule",
),
re_path(
f"^orga/event/(?P<event>[{SLUG_CHARS}]+)/p/lower-thirds/$",
views.LowerThirdsOrgaView.as_view(),
name="orga",
),
]

View File

@ -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"]