Order approval: Add attendee mail settings (Z#23114617, Z#23118978) (#3234)

Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
Phin Wolkwitz
2023-04-24 13:31:03 +02:00
committed by GitHub
parent 4fc6593b60
commit 73776ce0dd
5 changed files with 159 additions and 2 deletions

View File

@@ -391,9 +391,15 @@ def approve_order(order, user=None, send_mail: bool=True, auth=None, force=False
if order.total == Decimal('0.00'):
email_template = order.event.settings.mail_text_order_approved_free
email_subject = order.event.settings.mail_subject_order_approved_free
email_attendees = order.event.settings.mail_send_order_approved_free_attendee
email_attendee_template = order.event.settings.mail_text_order_approved_free_attendee
email_attendee_subject = order.event.settings.mail_subject_order_approved_free_attendee
else:
email_template = order.event.settings.mail_text_order_approved
email_subject = order.event.settings.mail_subject_order_approved
email_attendees = order.event.settings.mail_send_order_approved_attendee
email_attendee_template = order.event.settings.mail_text_order_approved_attendee
email_attendee_subject = order.event.settings.mail_subject_order_approved_attendee
email_context = get_email_context(event=order.event, order=order)
try:
@@ -406,6 +412,19 @@ def approve_order(order, user=None, send_mail: bool=True, auth=None, force=False
except SendMailException:
logger.exception('Order approved email could not be sent')
if email_attendees:
for p in order.positions.all():
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
email_attendee_context = get_email_context(event=order.event, order=order, position=p)
try:
p.send_mail(
email_attendee_subject, email_attendee_template, email_attendee_context,
'pretix.event.order.email.order_approved', user,
attach_tickets=True,
)
except SendMailException:
logger.exception('Order approved email could not be sent to attendee')
return order.pk

View File

@@ -2275,6 +2275,26 @@ You can select a payment method and perform the payment here:
{url}
Best regards,
Your {event} team"""))
},
'mail_send_order_approved_attendee': {
'type': bool,
'default': 'False'
},
'mail_subject_order_approved_attendee': {
'type': LazyI18nString,
'default': LazyI18nString.from_gettext(gettext_noop("Your event registration: {code}")),
},
'mail_text_order_approved_attendee': {
'type': LazyI18nString,
'default': LazyI18nString.from_gettext(gettext_noop("""Hello,
we approved a ticket ordered for you for {event}.
You can view the details and status of your ticket here:
{url}
Best regards,
Your {event} team"""))
},
@@ -2292,6 +2312,26 @@ at our event. As you only ordered free products, no payment is required.
You can change your order details and view the status of your order at
{url}
Best regards,
Your {event} team"""))
},
'mail_send_order_approved_free_attendee': {
'type': bool,
'default': 'False'
},
'mail_subject_order_approved_free_attendee': {
'type': LazyI18nString,
'default': LazyI18nString.from_gettext(gettext_noop("Your event registration: {code}")),
},
'mail_text_order_approved_free_attendee': {
'type': LazyI18nString,
'default': LazyI18nString.from_gettext(gettext_noop("""Hello,
we approved a ticket ordered for you for {event}.
You can view the details and status of your ticket here:
{url}
Best regards,
Your {event} team"""))
},