cleaning up email templates
This commit is contained in:
@@ -5,7 +5,7 @@ import gc
|
||||
import gzip
|
||||
import shutil
|
||||
import numpy as np
|
||||
|
||||
import re
|
||||
|
||||
from scipy import optimize
|
||||
|
||||
@@ -30,6 +30,13 @@ import pandas as pd
|
||||
|
||||
from django_rq import job
|
||||
from django.utils import timezone
|
||||
from django.utils.html import strip_tags
|
||||
|
||||
def textify(html):
|
||||
# Remove html tags and continuous whitespaces
|
||||
text_only = re.sub('[ \t]+', ' ', strip_tags(html))
|
||||
# Strip single spaces in the beginning of each line
|
||||
return text_only.replace('\n ', '\n').strip()
|
||||
|
||||
from utils import deserialize_list
|
||||
|
||||
@@ -640,9 +647,9 @@ def handle_sendemailcsv(first_name, last_name, email, csvfile,**kwargs):
|
||||
|
||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||
|
||||
text_content = plaintext.render(d)
|
||||
html_content = htmly.render(d)
|
||||
|
||||
text_content = textify(html_content)
|
||||
|
||||
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
|
||||
msg.attach_alternative(html_content, "text/html")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user