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