summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYingtong Li <runassudo@yingtongli.me>2020-05-10 22:32:49 +1000
committerYingtong Li <runassudo@yingtongli.me>2020-05-10 22:32:49 +1000
commit62119cc83c68ab696d95a4df9fc52e2d092c15fe (patch)
tree502329ac1bba8e9c2895d913f8b91cd433a5a0f1
parentfc1bb22dc48c44fb9151bd6e0a6cd8e017b883c5 (diff)
Better programmatic email generation
Allow different content for HTML vs text Automatically strip/tidy up text output
-rw-r--r--ssmain/email.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/ssmain/email.py b/ssmain/email.py
index 090f2fa..33363d9 100644
--- a/ssmain/email.py
+++ b/ssmain/email.py
@@ -87,10 +87,12 @@ class Emailer:
def render_mail(self, template_loc, params={}):
params['baseurl'] = 'https://' + settings.ALLOWED_HOSTS[0]
+ params['format'] = 'txt'
template = loader.get_template(template_loc)
- content_txt = template.render(params)
+ content_txt = template.render(params).strip().replace('\\*', '*')
- content_markdown = self.markdown(content_txt)
+ params['format'] = 'markdown'
+ content_markdown = self.markdown(template.render(params))
content_html = self.template.render({'email_content': Markup(content_markdown)})
content_html = premailer.Premailer(content_html, cssutils_logging_level=logging.ERROR, strip_important=False).transform()
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.