From 4d4b498636f27d5487aea0c2e36661cf7e71ef8d Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 29 Oct 2018 11:31:20 +0100 Subject: [PATCH] Resolve bug in event copy signals of pdf output and badges --- src/pretix/plugins/badges/signals.py | 11 ++++++++++- src/pretix/plugins/ticketoutputpdf/signals.py | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/pretix/plugins/badges/signals.py b/src/pretix/plugins/badges/signals.py index f6e70feab1..a4bdaacad1 100644 --- a/src/pretix/plugins/badges/signals.py +++ b/src/pretix/plugins/badges/signals.py @@ -1,4 +1,5 @@ import copy +import json from django.dispatch import receiver from django.template.loader import get_template @@ -62,13 +63,21 @@ def copy_item(sender, source, target, **kwargs): @receiver(signal=event_copy_data, dispatch_uid="badges_copy_data") -def event_copy_data_receiver(sender, other, item_map, **kwargs): +def event_copy_data_receiver(sender, other, question_map, item_map, **kwargs): layout_map = {} for bl in other.badge_layouts.all(): oldid = bl.pk bl = copy.copy(bl) bl.pk = None bl.event = sender + + layout = json.loads(bl.layout) + for o in layout: + if o['type'] == 'textarea': + if o['content'].startswith('question_'): + newq = question_map.get(int(o['content'][9:])) + if newq: + o['content'] = 'question_{}'.format(newq.pk) bl.save() if bl.background and bl.background.name: diff --git a/src/pretix/plugins/ticketoutputpdf/signals.py b/src/pretix/plugins/ticketoutputpdf/signals.py index 8f2944569b..551a01bc92 100644 --- a/src/pretix/plugins/ticketoutputpdf/signals.py +++ b/src/pretix/plugins/ticketoutputpdf/signals.py @@ -97,7 +97,9 @@ def pdf_event_copy_data_receiver(sender, other, item_map, question_map, **kwargs for o in layout: if o['type'] == 'textarea': if o['content'].startswith('question_'): - o['content'] = 'question_{}'.format(question_map.get(int(o['content'][9:]), 0).pk) + newq = question_map.get(int(o['content'][9:])) + if newq: + o['content'] = 'question_{}'.format(newq.pk) bl.layout = json.dumps(layout) bl.save()