From 6ede17d93f22f16eac400a0d24643196e3471735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Mon, 20 Apr 2020 11:23:07 +0300 Subject: [PATCH] Cleanup and comments. --- hc/lib/emails.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/hc/lib/emails.py b/hc/lib/emails.py index cb2c78fa..08f5b43d 100644 --- a/hc/lib/emails.py +++ b/hc/lib/emails.py @@ -32,8 +32,12 @@ def send(name, to, ctx, headers={}): t = EmailThread(subject, text, html, to, headers) if hasattr(settings, "BLOCKING_EMAILS"): + # In tests, we send emails synchronously + # so we can inspect the outgoing messages t.run() else: + # Outside tests, we send emails on thread, + # so there is no delay for the user. t.start() @@ -65,18 +69,6 @@ def report(to, ctx, headers={}): send("report", to, ctx, headers) -def invoice(to, ctx, filename, pdf_data): - ctx["SITE_ROOT"] = settings.SITE_ROOT - subject = render("emails/invoice-subject.html", ctx).strip() - text = render("emails/invoice-body-text.html", ctx) - html = render("emails/invoice-body-html.html", ctx) - - msg = EmailMultiAlternatives(subject, text, to=(to,)) - msg.attach_alternative(html, "text/html") - msg.attach(filename, pdf_data, "application/pdf") - msg.send() - - def deletion_notice(to, ctx, headers={}): send("deletion-notice", to, ctx, headers)