Private
Public Access
1
0

a few new email templates

This commit is contained in:
Sander Roosendaal
2018-03-19 15:49:57 +01:00
parent b744eff7f6
commit e7e2ced5f5
11 changed files with 254 additions and 88 deletions

View File

@@ -371,31 +371,34 @@ def handle_sendemail_hard(workoutid, useremail,
btvalues=pd.DataFrame().to_json(),
debug=False,**kwargs):
if 'debug' in kwargs:
debug = kwargs['debug']
else:
debug = False
siteurl = SITE_URL
if debug:
siteurl = SITE_URL_DEV
# send email with attachment
subject = "That was a pretty hard workout on rowsandall.com"
message = "Dear " + userfirstname + ",\n"
message += "Congratulations! Your recent workout has been analyzed"
message += " by Rowsandall.com and it appears that it was pretty hard work."
message += " You were working pretty close to your Critical Power\n\n"
message += " Critical Power (CP) is the power that you can "
message += "sustain for a given duration. For more, see this "
message += " article in the analytics blog:\n\n"
message += " http://analytics.rowsandall.com/2017/06/17/how-do-we-calculate-critical-power/ \n\n"
message += "Link to the workout: "+siteurl+"/rowers/workout/"
message += str(workoutid)
message += "/edit\n\n"
from_email = 'Rowsandall <info@rowsandall.com>'
message += "To opt out of these email notifications, deselect the checkbox on your Profile page under Account Information.\n\n"
htmly = get_template('hardemail.html')
message += "Best Regards, the Rowsandall Team"
d = {
'first_name':userfirstname,
'siteurl':siteurl,
'workoutid':workoutid,
'btvalues':tablevalues,
}
html_content = htmly.render(d)
text_content = textify(html_content)
msg = EmailMultiAlternatives(subject, text_content, from_email, [useremail])
msg.attach_alternative(html_content, "text/html")
email = EmailMessage(subject, message,
'Rowsandall <info@rowsandall.com>',
[useremail])
if 'emailbounced' in kwargs:
emailbounced = kwargs['emailbounced']
@@ -403,7 +406,7 @@ def handle_sendemail_hard(workoutid, useremail,
emailbounced = False
if not emailbounced:
res = email.send()
res = msg.send()
@@ -484,24 +487,19 @@ def handle_sendemail_unrecognizedowner(useremail, userfirstname,
# send email with attachment
fullemail = useremail
subject = "Unrecognized file from Rowsandall.com"
message = "Dear " + userfirstname + ",\n\n"
message += """
The file you tried to send to rowsandall.com was not recognized by
our email processing system. You may have sent a file in a format
that is not supported. Sometimes, rowing apps make file format changes.
When that happens, it takes some time for rowsandall.comm to make
the necessary changes on our side and support the app again.
The file has been sent to the developer at rowsandall.com for evaluation.
plaintext = get_template('csvemail.txt')
htmly = get_template('csvemail.html')
d = {'first_name':first_name}
"""
from_email = 'Rowsandall <info@rowsandall.com>'
message += "Best Regards, the Rowsandall Team"
html_content = htmly.render(d)
text_content = textify(html_content)
email = EmailMessage(subject, message,
'Rowsandall <info@rowsandall.com>',
[fullemail])
msg = EmailMultiAlternatives(subject, text_content, from_email, [fullemail])
msg.attach_alternative(html_content, "text/html")
if 'emailbounced' in kwargs:
emailbounced = kwargs['emailbounced']
@@ -509,7 +507,7 @@ def handle_sendemail_unrecognizedowner(useremail, userfirstname,
emailbounced = False
if not emailbounced:
res = email.send()
res = msg.send()
return 1
@@ -522,15 +520,20 @@ def handle_sendemailtcx(first_name, last_name, email, tcxfile,**kwargs):
# send email with attachment
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
subject = "File from Rowsandall.com"
message = "Dear " + first_name + ",\n\n"
message += "Please find attached the requested file for your workout.\n\n"
message += "Best Regards, the Rowsandall Team"
email = EmailMessage(subject, message,
'Rowsandall <info@rowsandall.com>',
[fullemail])
htmly = get_template('tcxemail.html')
email.attach_file(tcxfile)
d = {'first_name':first_name}
from_email = 'Rowsandall <info@rowsandall.com>'
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")
msg.attach_file(tcxfile)
if 'emailbounced' in kwargs:
emailbounced = kwargs['emailbounced']
@@ -538,7 +541,7 @@ def handle_sendemailtcx(first_name, last_name, email, tcxfile,**kwargs):
emailbounced = False
if not emailbounced:
res = email.send()
res = msg.send()
# remove tcx file
@@ -564,13 +567,8 @@ def handle_zip_file(emailfrom, subject, file,**kwargs):
if debug:
print "attaching"
if 'emailbounced' in kwargs:
emailbounced = kwargs['emailbounced']
else:
emailbounced = False
if not emailbounced:
res = email.send()
res = email.send()
if debug:
@@ -582,25 +580,30 @@ def handle_zip_file(emailfrom, subject, file,**kwargs):
@app.task
def handle_sendemailsummary(first_name, last_name, email, csvfile, **kwargs):
# send email with attachment
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
subject = "File from Rowsandall.com"
message = "Dear " + first_name + ",\n\n"
message += "Please find attached the requested summary file.\n\n"
message += "Best Regards, the Rowsandall Team"
email = EmailMessage(subject, message,
'Rowsandall <info@rowsandall.com>',
[fullemail])
htmly = get_template('summarymail.html')
d = {'first_name':first_name}
from_email = 'Rowsandall <info@rowsandall.com>'
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")
if os.path.isfile(csvfile):
email.attach_file(csvfile)
msg.attach_file(csvfile)
else:
csvfile2 = csvfile
with gzip.open(csvfile + '.gz', 'rb') as f_in, open(csvfile2, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
email.attach_file(csvfile2)
msg.attach_file(csvfile2)
os.remove(csvfile2)
if 'emailbounced' in kwargs:
@@ -609,7 +612,7 @@ def handle_sendemailsummary(first_name, last_name, email, csvfile, **kwargs):
emailbounced = False
if not emailbounced:
res = email.send()
res = msg.send()
try:
os.remove(csvfile)
@@ -781,24 +784,35 @@ def handle_otwsetpower(self,f1, boattype, weightvalue,
first_name,
last_name, btvalues=btvalues.to_json())
# send email
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
subject = "Your Rowsandall OTW calculations are ready"
message = "Dear " + first_name + ",\n\n"
message += "Your Rowsandall OTW calculations are ready.\n"
message += "Thank you for using rowsandall.com.\n\n"
message += "Rowsandall OTW calculations have not been fully implemented yet.\n"
message += "We are now running an experimental version for debugging purposes. \n"
message += "Your wind/stream corrected plot is available here: "
message += siteurl+"/rowers/workout/"
message += str(workoutid)
message += "/interactiveotwplot\n\n"
message += "Please report any bugs/inconsistencies/unexpected results at rowsandall.slack.com or by reply to this email.\n\n"
message += "Best Regards, The Rowsandall Physics Department."
send_mail(subject, message,
'Rowsandall Physics Department <info@rowsandall.com>',
[fullemail])
subject = "Your OTW Physics Calculations are ready"
from_email = 'Rowsandall <info@rowsandall.com>'
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
htmly = get_template('otwpoweremail.html')
d = {
'first_name':first_name,
'siteurl':siteurl,
'workoutid':workoutid,
}
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")
if 'emailbounced' in kwargs:
emailbounced = kwargs['emailbounced']
else:
emailbounced = False
if not emailbounced:
res = msg.send()
return 1

View File

@@ -1,10 +1,8 @@
<html>
<body>
{% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
<img src="https://rowsandall.com/static/img/logo7.png" height="50">
{% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p>
<p>
@@ -66,5 +64,5 @@
<p>
Best Regards, the Rowsandall Team
</p>
</html>
</body>
{% endblock %}

View File

@@ -1,6 +1,8 @@
<html>
<body>
<img src="https://rowsandall.com/static/img/logo7.png" height="50">
{% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p>
<p>
@@ -10,5 +12,4 @@
<p>
Best Regards, the Rowsandall Team
</p>
</body>
{% endblock %}

View File

@@ -1,5 +0,0 @@
Dear {{ first_name }},
Please find attached the requested file for your workout.
Best Regards, the Rowsandall Team

View File

@@ -0,0 +1,16 @@
<html>
<body>
<font face="verdana, sans-serif">
{% load staticfiles %}
{% load rowerfilters %}
<img src="https://rowsandall.com/static/img/logo7.png" height="50">
<font face="verdana, sans-serif">
{% block body %}
{% endblock %}
</font>
</body>
</html>

View File

@@ -0,0 +1,15 @@
{% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p>
<p>
Please find attached the requested file for your workout.
</p>
<p>
Best Regards, the Rowsandall Team
</p>
{% endblock %}

View File

@@ -0,0 +1,36 @@
{% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p>
<p>
Congratulations! Your recent workout has been analyzed
by Rowsandall.com and it appears it was pretty hard work.
You were working pretty close to your Critical Power.
Critical Power (CP) is the power that you can
sustain for a given duration. For more, see this
article in the analytics blog:
</p>
<p>
<a href="http://analytics.rowsandall.com/2017/06/17/how-do-we-calculate-critical-power/">
http://analytics.rowsandall.com/2017/06/17/how-do-we-calculate-critical-power/</a>
</p>
<p>
Link to the workout: <a href="{{ siteurl }}/rowers/workout/{{ workoutid }}">
{{ siteurl }}/rowers/workout/{{ workoutid }}</a>
</p>
<p>
To opt out of these email notifications, deselect the checkbox on your Profile
page under Account Information.
</p>
<p>
Best Regards, the Rowsandall Team
</p>
{% endblock %}

View File

@@ -0,0 +1,35 @@
{% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p>
<p>
Your Rowsandall OTW calculations are ready.
</p>
<p>
Thank you for using rowsandall.com.
</p>
<p>
Rowsandall OTW calculations have not been fully implemented yet.
</p>
<p>
We are now running an experimental version for debugging purposes.
</p>
<p>
Your wind/stream corrected plot is available here:
<a href="{{ siteurl }}/rowers/workout/{{ workoutid }}/interactiveotwplot">
{{ siteurl }}/rowers/workout/{{ workoutid }}/interactiveotwplot</a>
</p>
<p>
Please report any bugs/inconsistencies/unexpected results
by reply to this email.
</p>
<p>
Best Regards, the Rowsandall Physics Department
</p>
{% endblock %}

View File

@@ -0,0 +1,15 @@
{% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p>
<p>
Please find attached the requested summary file.
</p>
<p>
Best Regards, the Rowsandall Team
</p>
{% endblock %}

View File

@@ -0,0 +1,15 @@
{% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p>
<p>
Please find attached the requested file for your workout.
</p>
<p>
Best Regards, the Rowsandall Team
</p>
{% endblock %}

View File

@@ -0,0 +1,26 @@
{% extends "emailbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block body %}
<p>Dear <strong>{{ first_name }}</strong>,</p>
<p>
The file you tried to send to rowsandall.com was not recognized by
our email processing system. You may have sent a file in a format
that is not supported. Sometimes, rowing apps make file format changes.
When that happens, it takes some time for rowsandall.comm to make
the necessary changes on our side and support the app again.
</p>
<p>
The file has been sent to the developer at rowsandall.com for evaluation.
</p>
<p>
Best Regards, the Rowsandall Team
</p>
{% endblock %}