From 87cfd8f53809eec6d26edd8c8e084059336ae5e6 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 15 Sep 2022 13:35:35 +0200 Subject: [PATCH] Fix name placeholder not being used correctly in scheduled emails (#2794) --- src/pretix/base/email.py | 3 ++- src/pretix/plugins/sendmail/models.py | 5 +++-- src/pretix/plugins/sendmail/tasks.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pretix/base/email.py b/src/pretix/base/email.py index 1bfbbd9216..7da193470d 100644 --- a/src/pretix/base/email.py +++ b/src/pretix/base/email.py @@ -300,7 +300,8 @@ def get_email_context(**kwargs): kwargs.setdefault("position_or_address", kwargs['position']) if 'order' in kwargs: try: - kwargs['invoice_address'] = kwargs['order'].invoice_address + if not kwargs.get('invoice_address'): + kwargs['invoice_address'] = kwargs['order'].invoice_address except InvoiceAddress.DoesNotExist: kwargs['invoice_address'] = InvoiceAddress(order=kwargs['order']) finally: diff --git a/src/pretix/plugins/sendmail/models.py b/src/pretix/plugins/sendmail/models.py index e93cd05549..43d0e468d8 100644 --- a/src/pretix/plugins/sendmail/models.py +++ b/src/pretix/plugins/sendmail/models.py @@ -140,7 +140,7 @@ class ScheduledMail(models.Model): ia = InvoiceAddress(order=o) if send_to_orders and o.email: - email_ctx = get_email_context(event=e, order=o, position_or_address=ia) + email_ctx = get_email_context(event=e, order=o, invoice_address=ia) try: o.send_mail(self.rule.subject, self.rule.template, email_ctx, log_entry_type='pretix.plugins.sendmail.rule.order.email.sent') @@ -155,12 +155,13 @@ class ScheduledMail(models.Model): positions = [p for p in positions if p.subevent_id == self.subevent_id] for p in positions: - email_ctx = get_email_context(event=e, order=o, position_or_address=ia, position=p) try: if p.attendee_email and (p.attendee_email != o.email or not o_sent): + email_ctx = get_email_context(event=e, order=o, invoice_address=ia, position=p) p.send_mail(self.rule.subject, self.rule.template, email_ctx, log_entry_type='pretix.plugins.sendmail.rule.order.position.email.sent') elif not o_sent and o.email: + email_ctx = get_email_context(event=e, order=o, invoice_address=ia) o.send_mail(self.rule.subject, self.rule.template, email_ctx, log_entry_type='pretix.plugins.sendmail.rule.order.email.sent') o_sent = True diff --git a/src/pretix/plugins/sendmail/tasks.py b/src/pretix/plugins/sendmail/tasks.py index db4fe861c7..a326d0d945 100644 --- a/src/pretix/plugins/sendmail/tasks.py +++ b/src/pretix/plugins/sendmail/tasks.py @@ -87,7 +87,7 @@ def send_mails(event: Event, user: int, subject: dict, message: dict, orders: li try: with language(o.locale, event.settings.region): - email_context = get_email_context(event=event, order=o, position_or_address=p, position=p) + email_context = get_email_context(event=event, order=o, invoice_address=ia, position=p) mail( p.attendee_email, subject, @@ -116,7 +116,7 @@ def send_mails(event: Event, user: int, subject: dict, message: dict, orders: li if send_to_order and o.email: try: with language(o.locale, event.settings.region): - email_context = get_email_context(event=event, order=o, position_or_address=ia) + email_context = get_email_context(event=event, order=o, invoice_address=ia) mail( o.email, subject,