Attach receipt PDF to "payment successful" email #96850
@ -8,9 +8,10 @@ from django.dispatch import receiver
|
|||||||
from django.template import loader
|
from django.template import loader
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
import looper.signals
|
|
||||||
import looper.models
|
|
||||||
from . import models, signals
|
from . import models, signals
|
||||||
|
from looper.pdf import PDFResponse
|
||||||
|
import looper.models
|
||||||
|
import looper.signals
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -137,14 +138,19 @@ def automatic_payment_performed(sender: looper.models.Order,
|
|||||||
|
|
||||||
log.debug('Sending payment %r notification to %s', sender.status, email)
|
log.debug('Sending payment %r notification to %s', sender.status, email)
|
||||||
|
|
||||||
django.core.mail.send_mail(
|
msg = django.core.mail.EmailMultiAlternatives(
|
||||||
subject,
|
subject=subject,
|
||||||
message=email_body_txt,
|
body=email_body_txt,
|
||||||
html_message=email_body_html,
|
|
||||||
from_email=None, # just use the configured default From-address.
|
from_email=None, # just use the configured default From-address.
|
||||||
recipient_list=[email],
|
to=[email],
|
||||||
fail_silently=False,
|
|
||||||
)
|
)
|
||||||
|
file_data = b'TODO'
|
||||||
|
file_name = f'blender-development-fund-receipt-{sender.display_number}.pdf'
|
||||||
|
print(file_name)
|
||||||
|
file_data = PDFResponse().rendered_content
|
||||||
|
msg.attach(file_name, file_data, 'application/pdf')
|
||||||
|
msg.attach_alternative(email_body_html, 'text/html')
|
||||||
|
msg.send(fail_silently=False)
|
||||||
except Exception:
|
except Exception:
|
||||||
# Template rendering errors shouldn't interfere with the Looper clock, so
|
# Template rendering errors shouldn't interfere with the Looper clock, so
|
||||||
# catch all errors here.
|
# catch all errors here.
|
||||||
|
Loading…
Reference in New Issue
Block a user