From 25313bf044cab5bc8c01a896090215196e3ef00a Mon Sep 17 00:00:00 2001 From: Richard Schreiber Date: Tue, 10 May 2022 11:36:10 +0200 Subject: [PATCH] =?UTF-8?q?Add=20placeholder=20name=5Ffor=5Fsalutation=20t?= =?UTF-8?q?o=20editor/PDF=20to=20improve=20handling=20of=20salutation=20?= =?UTF-8?q?=E2=80=9EMx=E2=80=9C=20(#2639)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add name_for_salutation to editor/pdf * improve order of fields * add safe fallback for attendee_name_parts being None --- src/pretix/base/pdf.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pretix/base/pdf.py b/src/pretix/base/pdf.py index 7380c0edb..2d5710be1 100644 --- a/src/pretix/base/pdf.py +++ b/src/pretix/base/pdf.py @@ -549,6 +549,14 @@ def get_variables(event): v = copy.copy(DEFAULT_VARIABLES) scheme = PERSON_NAME_SCHEMES[event.settings.name_scheme] + + concatenation_for_salutation = scheme.get("concatenation_for_salutation", scheme["concatenation"]) + v['attendee_name_for_salutation'] = { + 'label': _("Attendee name for salutation"), + 'editor_sample': _("Mr Doe"), + 'evaluate': lambda op, order, ev: concatenation_for_salutation(op.attendee_name_parts or {}) + } + for key, label, weight in scheme['fields']: v['attendee_name_%s' % key] = { 'label': _("Attendee name: {part}").format(part=label), @@ -566,6 +574,12 @@ def get_variables(event): v['invoice_name']['editor_sample'] = scheme['concatenation'](scheme['sample']) v['attendee_name']['editor_sample'] = scheme['concatenation'](scheme['sample']) + v['invoice_name_for_salutation'] = { + 'label': _("Invoice address name for salutation"), + 'editor_sample': _("Mr Doe"), + 'evaluate': lambda op, order, ev: concatenation_for_salutation(order.invoice_address.name_parts if getattr(order, 'invoice_address', None) else {}) + } + for key, label, weight in scheme['fields']: v['invoice_name_%s' % key] = { 'label': _("Invoice address name: {part}").format(part=label),