Private
Public Access
1
0

fine tuning the sending of email notifications

This commit is contained in:
Sander Roosendaal
2022-12-17 17:08:25 +01:00
parent a7a33d0d17
commit 238856a224
2 changed files with 10 additions and 7 deletions

View File

@@ -82,6 +82,7 @@ from rowingdata import (
from rowers.dataroutines import * from rowers.dataroutines import *
from rowers.tasks import ( from rowers.tasks import (
handle_sendemail_newftp,
handle_sendemail_unrecognized, handle_setcp, handle_sendemail_unrecognized, handle_setcp,
handle_getagegrouprecords, handle_update_wps, handle_getagegrouprecords, handle_update_wps,
handle_request_post, handle_calctrimp, handle_request_post, handle_calctrimp,
@@ -735,8 +736,8 @@ def update_rolling_cp(r, types, mode='water'):
r.p3 = p1[3] r.p3 = p1[3]
r.cpratio = res2[3] r.cpratio = res2[3]
r.save() r.save()
if pwr > r.ftp*(100.-r.otwslack)/100. and r.getemailnotifications and not r.emailbounced: if pwr-5 > r.ftp*(100.-r.otwslack)/100. and r.getemailnotifications and not r.emailbounced:
_ = myqueue(queuehigh, handle_sendemail_newftp(r,pwr,'water')) _ = myqueue(queuehigh, handle_sendemail_newftp,r,pwr,'water')
else: else:
r.ep0 = p1[0] r.ep0 = p1[0]
@@ -745,8 +746,8 @@ def update_rolling_cp(r, types, mode='water'):
r.ep3 = p1[3] r.ep3 = p1[3]
r.ecpratio = res2[3] r.ecpratio = res2[3]
r.save() r.save()
if pwr > r.ftp and r.getemailnotifications and not r.emailbounced: if pwr-5 > r.ftp and r.getemailnotifications and not r.emailbounced:
_ = myqueue(queuehigh, handle_sendemail_newftp(r,pwr,'water')) _ = myqueue(queuehigh, handle_sendemail_newftp,r,pwr,'water')
return True return True

View File

@@ -1713,19 +1713,21 @@ def handle_sendemail_expired(useremail, userfirstname, userlastname, expireddate
return 1 return 1
@app.task @app.task
def handle_sendemail_newftp(power,rower,mode, **kwargs): def handle_sendemail_newftp(rower,power,mode, **kwargs):
subject = "You may want to update your FTP on rowsandall.com" subject = "You may want to update your FTP on rowsandall.com"
from_email = 'Rowsandall <info@rowsandall.com>' from_email = 'Rowsandall <info@rowsandall.com>'
power = int(power)
d = { d = {
'first_name': rower.user.first_name, 'first_name': rower.user.first_name,
'last_name': rower.user.last_name, 'last_name': rower.user.last_name,
'siteurl': siteurl, 'siteurl': siteurl,
'ftp': r.ftp, 'ftp': rower.ftp,
'newftp': power, 'newftp': power,
} }
_ = send_template_email(from_email, [r.user.email],
_ = send_template_email(from_email, [rower.user.email],
subject, 'newftpemail.html', subject, 'newftpemail.html',
d, **kwargs) d, **kwargs)