From 0bb610453249652995b79e2d66b2500dd0758cd6 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 16 Apr 2020 13:14:06 +0200 Subject: [PATCH] Flip order of invoices and tickets in email attachments --- src/pretix/base/services/mail.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/pretix/base/services/mail.py b/src/pretix/base/services/mail.py index 884f2e8edb..d4944bb1fa 100644 --- a/src/pretix/base/services/mail.py +++ b/src/pretix/base/services/mail.py @@ -276,20 +276,6 @@ def mail_send_task(self, *args, to: List[str], subject: str, body: str, html: st cm = lambda: scopes_disabled() # noqa with cm(): - if invoices: - invoices = Invoice.objects.filter(pk__in=invoices) - for inv in invoices: - if inv.file: - try: - with language(inv.order.locale): - email.attach( - pgettext('invoice', 'Invoice {num}').format(num=inv.number).replace(' ', '_') + '.pdf', - inv.file.file.read(), - 'application/pdf' - ) - except: - logger.exception('Could not attach invoice to email') - pass if event: if order: try: @@ -344,6 +330,21 @@ def mail_send_task(self, *args, to: List[str], subject: str, body: str, html: st email = email_filter.send_chained(event, 'message', message=email, order=order, user=user) + if invoices: + invoices = Invoice.objects.filter(pk__in=invoices) + for inv in invoices: + if inv.file: + try: + with language(inv.order.locale): + email.attach( + pgettext('invoice', 'Invoice {num}').format(num=inv.number).replace(' ', '_') + '.pdf', + inv.file.file.read(), + 'application/pdf' + ) + except: + logger.exception('Could not attach invoice to email') + pass + email = global_email_filter.send_chained(event, 'message', message=email, user=user, order=order) try: