1
0
Fork 0
mirror of https://github.com/Kunsi/pretalx-plugin-broadcast-tools synced 2024-04-29 14:27:22 +00:00

add option to include additional custom content on pdf export

This commit is contained in:
Franzi 2022-11-15 13:43:17 +01:00
parent 280458f6aa
commit a272f21498
Signed by: kunsi
GPG key ID: 12E3D2136B818350
5 changed files with 51 additions and 16 deletions

View file

@ -17,6 +17,8 @@ from reportlab.platypus import (
TableStyle,
)
from .utils.placeholders import placeholders
A4_WIDTH, A4_HEIGHT = A4
PAGE_PADDING = 10 * mm
@ -169,6 +171,17 @@ class PDFInfoPage(Flowable):
)
)
if self.event.settings.broadcast_tools_pdf_additional_content:
self._space()
self._add(
Paragraph(
self.event.settings.broadcast_tools_pdf_additional_content.format(
**placeholders(self.schedule, self.talk)
),
style=self.style["Meta"],
)
)
if self.talk.submission.answers and self._questions:
self._space()
self._add(

View file

@ -1,4 +1,4 @@
from django.forms import BooleanField, CharField
from django.forms import BooleanField, CharField, Textarea
from django.utils.translation import gettext_lazy as _
from hierarkey.forms import HierarkeyForm
from i18nfield.forms import I18nFormField, I18nFormMixin, I18nTextInput
@ -14,7 +14,10 @@ class BroadcastToolsSettingsForm(I18nFormMixin, HierarkeyForm):
required=True,
)
broadcast_tools_lower_thirds_info_string = I18nFormField(
help_text=_("Will only be shown if there's a talk running."),
help_text=_(
"Will only be shown if there's a talk running. You may use "
"the place holders mentioned below."
),
label=_("info line"),
required=False,
widget=I18nTextInput,
@ -43,3 +46,13 @@ class BroadcastToolsSettingsForm(I18nFormMixin, HierarkeyForm):
label=_("Questions to include"),
required=False,
)
broadcast_tools_pdf_additional_content = CharField(
help_text=_(
"Additional content to print onto the PDF export. "
"Will get printed as-is. You may use the place holders "
"mentioned below."
),
label=_("Additional Text"),
required=False,
widget=Textarea,
)

View file

@ -17,15 +17,6 @@
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>
{% if request.event.rooms %}
<h3>{% trans "room list" %}</h3>
@ -43,8 +34,23 @@
{% bootstrap_field form.broadcast_tools_pdf_show_internal_notes layout='event' %}
{% bootstrap_field form.broadcast_tools_pdf_ignore_do_not_record layout='event' %}
{% bootstrap_field form.broadcast_tools_pdf_questions_to_include layout='event' %}
{% bootstrap_field form.broadcast_tools_pdf_additional_content layout='event' %}
</fieldset>
<fieldset>
<p>
pretalx will automatically replace some placeholders in your custom
content:
</p>
<dl>
<dt><code>{CODE}</code></dt>
<dd>Use to embed the talk code (<code>MUX9U3</code> for example).</dd>
<dt><code>{EVENT_SLUG}</code></dt>
<dd>Use to embed the event slug.</dd>
<dt><code>{TALK_SLUG}</code></dt>
<dd>Use to embed the talk slug.</dd>
</dl>
<div class="submit-group panel">
<span></span>
<span class="d-flex flex-row-reverse">

View file

@ -0,0 +1,6 @@
def placeholders(schedule, talk):
return {
"EVENT_SLUG": str(schedule.event.slug),
"TALK_SLUG": talk.frab_slug,
"CODE": talk.submission.code,
}

View file

@ -9,6 +9,7 @@ from pretalx.common.mixins.views import EventPermissionRequired, PermissionRequi
from pretalx.schedule.exporters import ScheduleData
from .forms import BroadcastToolsSettingsForm
from .utils.placeholders import placeholders
class BroadcastToolsLowerThirdsView(TemplateView):
@ -99,11 +100,7 @@ class BroadcastToolsScheduleView(EventPermissionRequired, ScheduleMixin, Templat
if talk.submission.track
else None,
"room": str(room["name"]),
"infoline": infoline.format(
EVENT_SLUG=str(schedule.event.slug),
TALK_SLUG=talk.frab_slug,
CODE=talk.submission.code,
),
"infoline": infoline.format(**placeholders(schedule, talk)),
}
for day in schedule.data
for room in day["rooms"]