From 324c017f359f08bd6e0ec9bcaea909c270770d76 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Thu, 22 Aug 2019 16:58:32 +0200
Subject: [PATCH] adding some info to email
---
rowers/management/commands/processalerts.py | 23 ++++++++++++++++++++-
rowers/tasks.py | 6 ++++++
rowers/templates/alertemail.html | 6 ++++++
3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/rowers/management/commands/processalerts.py b/rowers/management/commands/processalerts.py
index 37dce806..6c0034c0 100644
--- a/rowers/management/commands/processalerts.py
+++ b/rowers/management/commands/processalerts.py
@@ -42,6 +42,26 @@ class Command(BaseCommand):
for alert in todaysalerts:
stats = alerts.alert_get_stats(alert)
+
+ # explanatorytexts
+ if alert.measured.condition == 'between':
+ description = 'This alert measures strokes where {metric} is between {value1} and {value2}.'.format(
+ metric = alert.measured.metric,
+ value1 = alert.measured.value1,
+ value2 = alert.measured.value2,
+ )
+ elif alert.measured.condition == '<':
+ description = 'This alert measures strokes where {metric} is smaller than {value1}.'.format(
+ metric = alert.measured.metric,
+ value1 = alert.measured.value1,
+ )
+ else:
+ description = 'This alert measures strokes where {metric} is larger than {value1}.'.format(
+ metric = alert.measured.metric,
+ value1 = alert.measured.value1,
+ )
+
+ othertexts = [description]
# send email
job = myqueue(queue,handle_send_email_alert,
@@ -50,7 +70,8 @@ class Command(BaseCommand):
alert.manager.last_name,
alert.rower.user.first_name,
alert.name,
- stats,debug=True)
+ stats,debug=True,
+ othertexts=othertexts)
# advance next_run
if not testing:
diff --git a/rowers/tasks.py b/rowers/tasks.py
index dbd1f774..3aab4fbe 100644
--- a/rowers/tasks.py
+++ b/rowers/tasks.py
@@ -765,6 +765,11 @@ def handle_send_email_alert(
else:
debug = False
+ if 'othertexts' in kwargs:
+ othertexts = kwargs['othertexts']
+ else:
+ othertexts = None
+
subject = "Your rowing performance on rowsandall.com ({startdate} to {enddate})".format(
startdate = stats['startdate'],
enddate = stats['enddate'],
@@ -779,6 +784,7 @@ def handle_send_email_alert(
'siteurl':siteurl,
'rowerfirstname':rowerfirstname,
'alertname':alertname,
+ 'othertexts':othertexts,
}
res = send_template_email(from_email,[useremail],subject,
diff --git a/rowers/templates/alertemail.html b/rowers/templates/alertemail.html
index 7a05bc84..d94263dd 100644
--- a/rowers/templates/alertemail.html
+++ b/rowers/templates/alertemail.html
@@ -7,6 +7,12 @@
Here is the report for your alert {{ alertname }} on rowsandall.com. This is a report for your athlete {{ rowerfirstname }}.
+{% for text in othertexts %}
+
+ {{ text|safe }}
+
+{% endfor %}
+
{% for key, value in report.items() %}
{{ key }}: {{ value }}