mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Make sure correct language is active when generating email attachments
This commit is contained in:
@@ -283,50 +283,51 @@ def mail_send_task(self, *args, to: List[str], subject: str, body: str, html: st
|
|||||||
except Order.DoesNotExist:
|
except Order.DoesNotExist:
|
||||||
order = None
|
order = None
|
||||||
else:
|
else:
|
||||||
if position:
|
with language(order.locale):
|
||||||
try:
|
if position:
|
||||||
position = order.positions.get(pk=position)
|
try:
|
||||||
except OrderPosition.DoesNotExist:
|
position = order.positions.get(pk=position)
|
||||||
attach_tickets = False
|
except OrderPosition.DoesNotExist:
|
||||||
if attach_tickets:
|
attach_tickets = False
|
||||||
args = []
|
if attach_tickets:
|
||||||
attach_size = 0
|
args = []
|
||||||
for name, ct in get_tickets_for_order(order, base_position=position):
|
attach_size = 0
|
||||||
content = ct.file.read()
|
for name, ct in get_tickets_for_order(order, base_position=position):
|
||||||
args.append((name, content, ct.type))
|
content = ct.file.read()
|
||||||
attach_size += len(content)
|
args.append((name, content, ct.type))
|
||||||
|
attach_size += len(content)
|
||||||
|
|
||||||
if attach_size < 4 * 1024 * 1024:
|
if attach_size < 4 * 1024 * 1024:
|
||||||
# Do not attach more than 4MB, it will bounce way to often.
|
# Do not attach more than 4MB, it will bounce way to often.
|
||||||
for a in args:
|
for a in args:
|
||||||
try:
|
try:
|
||||||
email.attach(*a)
|
email.attach(*a)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
|
||||||
order.log_action(
|
|
||||||
'pretix.event.order.email.attachments.skipped',
|
|
||||||
data={
|
|
||||||
'subject': 'Attachments skipped',
|
|
||||||
'message': 'Attachment have not been send because {} bytes are likely too large to arrive.'.format(attach_size),
|
|
||||||
'recipient': '',
|
|
||||||
'invoices': [],
|
|
||||||
}
|
|
||||||
)
|
|
||||||
if attach_ical:
|
|
||||||
ical_events = set()
|
|
||||||
if event.has_subevents:
|
|
||||||
if position:
|
|
||||||
ical_events.add(position.subevent)
|
|
||||||
else:
|
else:
|
||||||
for p in order.positions.all():
|
order.log_action(
|
||||||
ical_events.add(p.subevent)
|
'pretix.event.order.email.attachments.skipped',
|
||||||
else:
|
data={
|
||||||
ical_events.add(order.event)
|
'subject': 'Attachments skipped',
|
||||||
|
'message': 'Attachment have not been send because {} bytes are likely too large to arrive.'.format(attach_size),
|
||||||
|
'recipient': '',
|
||||||
|
'invoices': [],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if attach_ical:
|
||||||
|
ical_events = set()
|
||||||
|
if event.has_subevents:
|
||||||
|
if position:
|
||||||
|
ical_events.add(position.subevent)
|
||||||
|
else:
|
||||||
|
for p in order.positions.all():
|
||||||
|
ical_events.add(p.subevent)
|
||||||
|
else:
|
||||||
|
ical_events.add(order.event)
|
||||||
|
|
||||||
for i, e in enumerate(ical_events):
|
for i, e in enumerate(ical_events):
|
||||||
cal = get_ical([e])
|
cal = get_ical([e])
|
||||||
email.attach('event-{}.ics'.format(i), cal.serialize(), 'text/calendar')
|
email.attach('event-{}.ics'.format(i), cal.serialize(), 'text/calendar')
|
||||||
|
|
||||||
email = email_filter.send_chained(event, 'message', message=email, order=order, user=user)
|
email = email_filter.send_chained(event, 'message', message=email, order=order, user=user)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user