alert email
This commit is contained in:
@@ -756,6 +756,26 @@ def handle_updatedps(useremail, workoutids, debug=False,**kwargs):
|
||||
|
||||
return 1
|
||||
|
||||
import math
|
||||
def sigdig(value, digits = 3):
|
||||
try:
|
||||
order = int(math.floor(math.log10(math.fabs(value))))
|
||||
except (ValueError,TypeError):
|
||||
return value
|
||||
|
||||
# return integers as is
|
||||
if value % 1 == 0:
|
||||
return value
|
||||
|
||||
places = digits - order - 1
|
||||
if places > 0:
|
||||
fmtstr = "%%.%df" % (places)
|
||||
else:
|
||||
fmtstr = "%.0f"
|
||||
return fmtstr % (round(value, places))
|
||||
|
||||
|
||||
|
||||
@app.task
|
||||
def handle_send_email_alert(
|
||||
useremail, userfirstname, userlastname, rowerfirstname, alertname, stats, **kwargs):
|
||||
@@ -770,15 +790,26 @@ def handle_send_email_alert(
|
||||
else:
|
||||
othertexts = None
|
||||
|
||||
subject = "Your rowing performance on rowsandall.com ({startdate} to {enddate})".format(
|
||||
report = {}
|
||||
report['Percentage'] = int(stats['percentage'])
|
||||
report['Number of workouts'] = int(stats['workouts'])
|
||||
report['Data set'] = "{a} strokes out of {b}".format(
|
||||
a = stats['nr_strokes_qualifying'],
|
||||
b = stats['nr_strokes']
|
||||
)
|
||||
report['Median'] = sigdig(stats['median'])
|
||||
report['Median of qualifying strokes'] = sigdig(stats['median_q'])
|
||||
|
||||
subject = "Rowsandall.com: {alertname} ({startdate} to {enddate})".format(
|
||||
startdate = stats['startdate'],
|
||||
enddate = stats['enddate'],
|
||||
alertname=alertname,
|
||||
)
|
||||
|
||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||
|
||||
d = {
|
||||
'report':stats,
|
||||
'report':report,
|
||||
'first_name':userfirstname,
|
||||
'last_name':userlastname,
|
||||
'siteurl':siteurl,
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Rowsandall</title>
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<font face="verdana, sans-serif">
|
||||
|
||||
|
||||
<img src="https://rowsandall.com/static/img/logoemail.png" height="50">
|
||||
<font face="verdana, sans-serif">
|
||||
{% block body %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
<img src="https://rowsandall.com/static/img/logoemail.png" height="50">
|
||||
<font face="verdana, sans-serif">
|
||||
{% block body %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
</font>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user