forked from CGM_Public/pretix_original
Fix scoping issue in mail_send_task
This commit is contained in:
@@ -220,19 +220,6 @@ def mail_send_task(self, *args, to: List[str], subject: str, body: str, html: st
|
|||||||
email = EmailMultiAlternatives(subject, body, sender, to=to, bcc=bcc, headers=headers)
|
email = EmailMultiAlternatives(subject, body, sender, to=to, bcc=bcc, headers=headers)
|
||||||
if html is not None:
|
if html is not None:
|
||||||
email.attach_alternative(html, "text/html")
|
email.attach_alternative(html, "text/html")
|
||||||
if invoices:
|
|
||||||
invoices = Invoice.objects.filter(pk__in=invoices)
|
|
||||||
for inv in invoices:
|
|
||||||
if inv.file:
|
|
||||||
try:
|
|
||||||
email.attach(
|
|
||||||
'{}.pdf'.format(inv.number),
|
|
||||||
inv.file.file.read(),
|
|
||||||
'application/pdf'
|
|
||||||
)
|
|
||||||
except:
|
|
||||||
logger.exception('Could not attach invoice to email')
|
|
||||||
pass
|
|
||||||
|
|
||||||
if event:
|
if event:
|
||||||
with scopes_disabled():
|
with scopes_disabled():
|
||||||
@@ -244,6 +231,19 @@ def mail_send_task(self, *args, to: List[str], subject: str, body: str, html: st
|
|||||||
cm = lambda: scopes_disabled() # noqa
|
cm = lambda: scopes_disabled() # noqa
|
||||||
|
|
||||||
with cm():
|
with cm():
|
||||||
|
if invoices:
|
||||||
|
invoices = Invoice.objects.filter(pk__in=invoices)
|
||||||
|
for inv in invoices:
|
||||||
|
if inv.file:
|
||||||
|
try:
|
||||||
|
email.attach(
|
||||||
|
'{}.pdf'.format(inv.number),
|
||||||
|
inv.file.file.read(),
|
||||||
|
'application/pdf'
|
||||||
|
)
|
||||||
|
except:
|
||||||
|
logger.exception('Could not attach invoice to email')
|
||||||
|
pass
|
||||||
if event:
|
if event:
|
||||||
if order:
|
if order:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user