diff --git a/rowers/alerts.py b/rowers/alerts.py index 5d8106c5..f1c73fdb 100644 --- a/rowers/alerts.py +++ b/rowers/alerts.py @@ -211,11 +211,17 @@ def alert_get_stats(alert, nperiod=0): # pragma: no cover # run alert report # check alert permission - +from django.utils import timezone def checkalertowner(alert, user): if alert.manager == user: return True if alert.rower.user == user: # pragma: no cover return True + coaches = alert.manager.rower.get_coaches() + for coach in coaches: + if coach.rowerplan == 'coach': + return True + if coach.coachtrialexpires >= timezone.now().date(): + return True return False # pragma: no cover diff --git a/rowers/dataprep.py b/rowers/dataprep.py index 86f13ab6..a02c5ce3 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -980,6 +980,13 @@ def checkbreakthrough(w, r): r.user.first_name, r.user.last_name, btvalues=btvalues.to_json()) + for coach in r.get_coaches(): + _ = myqueue(queuehigh, handle_sendemail_breakthrough, + w.id, + coach.user.email, + r.user.first_name, + r.user.last_name, + btvalues=btvalues.to_json()) # submit email task to send email about breakthrough workout if ishard: # pragma: no cover @@ -993,6 +1000,13 @@ def checkbreakthrough(w, r): r.user.first_name, r.user.last_name, btvalues=btvalues.to_json()) + for coach in r.get_coaches(): + _ = myqueue(queuehigh, handle_sendemail_hard, + w.id, + coach.user.email, + r.user.first_name, + r.user.last_name, + btvalues=btvalues.to_json()) return isbreakthrough, ishard diff --git a/rowers/management/commands/processalerts.py b/rowers/management/commands/processalerts.py index d910de93..04ca937c 100644 --- a/rowers/management/commands/processalerts.py +++ b/rowers/management/commands/processalerts.py @@ -52,6 +52,7 @@ class Command(BaseCommand): alert.manager.first_name, alert.manager.last_name, alert.rower.user.first_name, + alert.rower.user.last_name, alert.name, stats, debug=True, othertexts=othertexts) diff --git a/rowers/tasks.py b/rowers/tasks.py index f6499009..f9c3e990 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -1304,7 +1304,8 @@ def sigdig(value, digits=3): @app.task def handle_send_email_alert( - useremail, userfirstname, userlastname, rowerfirstname, alertname, stats, **kwargs): + useremail, userfirstname, userlastname, rowerfirstname, rowerlastname, + alertname, stats, **kwargs): if 'othertexts' in kwargs: # pragma: no cover othertexts = kwargs['othertexts'] @@ -1356,6 +1357,7 @@ def handle_send_email_alert( 'enddate': stats['enddate'], 'siteurl': siteurl, 'rowerfirstname': rowerfirstname, + 'rowerlastname': rowerlastname, 'alertname': alertname, 'othertexts': othertexts, } diff --git a/rowers/templates/alertemail.html b/rowers/templates/alertemail.html index 1d737ccc..39fc8dae 100644 --- a/rowers/templates/alertemail.html +++ b/rowers/templates/alertemail.html @@ -4,7 +4,8 @@
Dear {{ first_name }},
- Here is the report for your alert {{ alertname }} on rowsandall.com. This is a report for your athlete {{ rowerfirstname }}, covering the period from + Here is the report for your alert {{ alertname }} on rowsandall.com. + This is a report for your athlete {{ rowerfirstname }} {{ rowerlastname }}, covering the period from {{ startdate }} to {{ enddate }}.
@@ -24,4 +25,3 @@ Best Regards, the Rowsandall Team {% endblock %} -