added breakthrough notification
This commit is contained in:
@@ -311,55 +311,43 @@ def handle_sendemail_breakthrough(workoutid, useremail,
|
|||||||
btvalues=pd.DataFrame().to_json(),
|
btvalues=pd.DataFrame().to_json(),
|
||||||
**kwargs):
|
**kwargs):
|
||||||
|
|
||||||
|
if 'debug' in kwargs:
|
||||||
|
debug = kwargs['debug']
|
||||||
|
else:
|
||||||
|
debug = False
|
||||||
|
|
||||||
siteurl = SITE_URL
|
siteurl = SITE_URL
|
||||||
if debug:
|
if debug:
|
||||||
siteurl = SITE_URL_DEV
|
siteurl = SITE_URL_DEV
|
||||||
|
|
||||||
# send email with attachment
|
|
||||||
subject = "A breakthrough workout on rowsandall.com"
|
|
||||||
message = "Dear " + userfirstname + ",\n"
|
|
||||||
message += "Congratulations! Your recent workout has been analyzed"
|
|
||||||
message += " by Rowsandall.com and it appears your fitness,"
|
|
||||||
message += " as measured by Critical Power, has improved!"
|
|
||||||
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"
|
|
||||||
message += "To add the workout to your Ranking workouts and see the updated CP plot, click the following link:\n"
|
|
||||||
message += siteurl+"/rowers/workout/"
|
|
||||||
message += str(workoutid)
|
|
||||||
message += "/updatecp\n\n"
|
|
||||||
|
|
||||||
btvalues = pd.read_json(btvalues)
|
btvalues = pd.read_json(btvalues)
|
||||||
btvalues.sort_values('delta', axis=0, inplace=True)
|
btvalues.sort_values('delta', axis=0, inplace=True)
|
||||||
|
|
||||||
if not btvalues.empty:
|
tablevalues = [
|
||||||
message += "These were the breakthrough values:\n"
|
{'delta': t.delta,
|
||||||
for t in btvalues.itertuples():
|
'cpvalue': t.cpvalues,
|
||||||
delta = t.delta
|
'pwr': t.pwr
|
||||||
cpvalue = t.cpvalues
|
} for t in btvalues.itertuples()
|
||||||
pwr = t.pwr
|
]
|
||||||
|
|
||||||
message += "Time: {delta} seconds\n".format(
|
# send email with attachment
|
||||||
delta=delta
|
subject = "A breakthrough workout on rowsandall.com"
|
||||||
)
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
message += "New: {cpvalue:.0f} Watt\n".format(
|
|
||||||
cpvalue=cpvalue
|
|
||||||
)
|
|
||||||
message += "Old: {pwr:.0f} Watt\n\n".format(
|
|
||||||
pwr=pwr
|
|
||||||
)
|
|
||||||
|
|
||||||
message += "To opt out of these email notifications, deselect the checkbox on your Profile page under Account Information.\n\n"
|
htmly = get_template('breakthroughemail.html')
|
||||||
|
|
||||||
message += "Best Regards, the Rowsandall Team"
|
d = {
|
||||||
|
'first_name':userfirstname,
|
||||||
|
'siteurl':siteurl,
|
||||||
|
'workoutid':workoutid,
|
||||||
|
'btvalues':tablevalues,
|
||||||
|
}
|
||||||
|
|
||||||
email = EmailMessage(subject, message,
|
html_content = htmly.render(d)
|
||||||
'Rowsandall <info@rowsandall.com>',
|
text_content = textify(html_content)
|
||||||
[useremail])
|
|
||||||
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [useremail])
|
||||||
|
msg.attach_alternative(html_content, "text/html")
|
||||||
|
|
||||||
if 'emailbounced' in kwargs:
|
if 'emailbounced' in kwargs:
|
||||||
emailbounced = kwargs['emailbounced']
|
emailbounced = kwargs['emailbounced']
|
||||||
@@ -367,7 +355,7 @@ def handle_sendemail_breakthrough(workoutid, useremail,
|
|||||||
emailbounced = False
|
emailbounced = False
|
||||||
|
|
||||||
if not emailbounced:
|
if not emailbounced:
|
||||||
res = email.send()
|
res = msg.send()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
70
rowers/templates/breakthroughemail.html
Normal file
70
rowers/templates/breakthroughemail.html
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
|
||||||
|
<img src="https://rowsandall.com/static/img/logo7.png" height="50">
|
||||||
|
<p>Dear <strong>{{ first_name }}</strong>,</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Congratulations! Your recent workout has been analyzed
|
||||||
|
by Rowsandall.com and it appears your fitness,
|
||||||
|
as measured by Critical Power, has improved!
|
||||||
|
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 add the workout to your Ranking workouts and see the updated CP plot,
|
||||||
|
click the following link:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="{{ siteurl }}/rowers/workout/{{ workoutid }}/updatecp">
|
||||||
|
{{ siteurl }}/rowers/workout/{{ workoutid }}/updatecp</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% if btvalues %}
|
||||||
|
<p>
|
||||||
|
These were the breakthrough values:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Time (sec)</th><th>New Power (W)</th><th>Old Power </th>
|
||||||
|
</tr>
|
||||||
|
{% for set in btvalues %}
|
||||||
|
<tr>
|
||||||
|
<th>{{ set|lookup:"delta" }}</th>
|
||||||
|
<th>{{ set|lookup:"cpvalue" }}</th>
|
||||||
|
<th>{{ set|lookup:"pwr" }}</th>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
||||||
|
</html>
|
||||||
|
</body>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<img src="https://rowsandall.com/static/img/logo7.png" height="50"</img>
|
<img src="https://rowsandall.com/static/img/logo7.png" height="50">
|
||||||
<p>Dear <strong>{{ first_name }}</strong>,</p>
|
<p>Dear <strong>{{ first_name }}</strong>,</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
Reference in New Issue
Block a user