1
0
Fork 0
mirror of https://github.com/Kunsi/pretalx-plugin-broadcast-tools synced 2024-11-22 01:31:02 +00:00

add option to be able to choose which questions to include in pdf export

This commit is contained in:
Franzi 2022-11-07 03:59:41 +01:00
parent 5930907aa1
commit bfbce9e98b
Signed by: kunsi
GPG key ID: 12E3D2136B818350
3 changed files with 26 additions and 3 deletions

View file

@ -32,6 +32,16 @@ class PDFInfoPage(Flowable):
self.style = style self.style = style
self.y_position = PAGE_PADDING self.y_position = PAGE_PADDING
@property
def _questions(self):
return {
int(i.strip())
for i in self.event.settings.broadcast_tools_pdf_questions_to_include.split(
","
)
if i
}
def _add(self, item, gap=2): def _add(self, item, gap=2):
_, height = item.wrapOn( _, height = item.wrapOn(
self.canv, A4_WIDTH - 2 * PAGE_PADDING, A4_HEIGHT - 2 * PAGE_PADDING self.canv, A4_WIDTH - 2 * PAGE_PADDING, A4_HEIGHT - 2 * PAGE_PADDING
@ -157,9 +167,11 @@ class PDFInfoPage(Flowable):
) )
) )
if self.talk.submission.answers: if self.talk.submission.answers and self._questions:
self._space() self._space()
for answer in sorted(self.talk.submission.answers.all()): for answer in sorted(self.talk.submission.answers.all()):
if answer.question.id not in self._questions:
continue
self._question_text( self._question_text(
str(answer.question.question), str(answer.question.question),
answer.answer, answer.answer,
@ -246,7 +258,9 @@ class PDFExporter(ScheduleData):
ParagraphStyle(name="Meta", fontName="Helvetica", fontSize=14, leading=16) ParagraphStyle(name="Meta", fontName="Helvetica", fontSize=14, leading=16)
) )
stylesheet.add( stylesheet.add(
ParagraphStyle(name="Question", fontName="Helvetica", fontSize=12, leading=14) ParagraphStyle(
name="Question", fontName="Helvetica", fontSize=12, leading=14
)
) )
stylesheet.add( stylesheet.add(
ParagraphStyle( ParagraphStyle(

View file

@ -1,4 +1,4 @@
from django.forms import BooleanField from django.forms import BooleanField, CharField
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from hierarkey.forms import HierarkeyForm from hierarkey.forms import HierarkeyForm
from i18nfield.forms import I18nFormField, I18nFormMixin, I18nTextInput from i18nfield.forms import I18nFormField, I18nFormMixin, I18nTextInput
@ -35,3 +35,11 @@ class BroadcastToolsSettingsForm(I18nFormMixin, HierarkeyForm):
label=_("Ignore 'do not record' talks when generating pdf"), label=_("Ignore 'do not record' talks when generating pdf"),
required=False, required=False,
) )
broadcast_tools_pdf_questions_to_include = CharField(
help_text=_(
"Comma-Separated list of question ids to include in pdf export. "
"If empty, no questions will get added."
),
label=_("Questions to include"),
required=False,
)

View file

@ -42,6 +42,7 @@
</legend> </legend>
{% bootstrap_field form.broadcast_tools_pdf_show_internal_notes layout='event' %} {% 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_ignore_do_not_record layout='event' %}
{% bootstrap_field form.broadcast_tools_pdf_questions_to_include layout='event' %}
</fieldset> </fieldset>
<fieldset> <fieldset>
<div class="submit-group panel"> <div class="submit-group panel">