Browse Source

Cleanup and comments.

pull/366/head
Pēteris Caune 5 years ago
parent
commit
6ede17d93f
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
1 changed files with 4 additions and 12 deletions
  1. +4
    -12
      hc/lib/emails.py

+ 4
- 12
hc/lib/emails.py View File

@ -32,8 +32,12 @@ def send(name, to, ctx, headers={}):
t = EmailThread(subject, text, html, to, headers) t = EmailThread(subject, text, html, to, headers)
if hasattr(settings, "BLOCKING_EMAILS"): if hasattr(settings, "BLOCKING_EMAILS"):
# In tests, we send emails synchronously
# so we can inspect the outgoing messages
t.run() t.run()
else: else:
# Outside tests, we send emails on thread,
# so there is no delay for the user.
t.start() t.start()
@ -65,18 +69,6 @@ def report(to, ctx, headers={}):
send("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={}): def deletion_notice(to, ctx, headers={}):
send("deletion-notice", to, ctx, headers) send("deletion-notice", to, ctx, headers)


Loading…
Cancel
Save