send email when course fails
This commit is contained in:
@@ -119,7 +119,11 @@ siteurl = SITE_URL
|
||||
# testing task
|
||||
|
||||
from rowers.emails import send_template_email
|
||||
from rowers.courseutils import coursetime_paths, coursetime_first, time_in_path
|
||||
from rowers.courseutils import (
|
||||
coursetime_paths, coursetime_first, time_in_path,
|
||||
InvalidTrajectoryError
|
||||
)
|
||||
|
||||
|
||||
@app.task
|
||||
def add(x, y):
|
||||
@@ -342,7 +346,8 @@ def polygon_to_path(polygon,debug=True):
|
||||
@app.task(bind=True)
|
||||
def handle_check_race_course(self,
|
||||
f1,workoutid,courseid,
|
||||
recordid,**kwargs):
|
||||
recordid,useremail,userfirstname,
|
||||
**kwargs):
|
||||
|
||||
if 'debug' in kwargs:
|
||||
debug = kwargs['debug']
|
||||
@@ -432,7 +437,15 @@ def handle_check_race_course(self,
|
||||
paths.append(path)
|
||||
|
||||
# check how many times went through start polygon
|
||||
entrytimes,entrydistances = time_in_path(rowdata,paths[0],maxmin='max',getall=True)
|
||||
try:
|
||||
entrytimes,entrydistances = time_in_path(rowdata,paths[0],maxmin='max',getall=True)
|
||||
except InvalidTrajectoryError:
|
||||
entrytimes = []
|
||||
entrydistances = []
|
||||
coursecompleted = False
|
||||
coursemeters = 0
|
||||
coursetimeseconds = 0
|
||||
|
||||
|
||||
cseconds = []
|
||||
cmeters = []
|
||||
@@ -528,6 +541,39 @@ def handle_check_race_course(self,
|
||||
return 1
|
||||
|
||||
else:
|
||||
query = 'UPDATE rowers_virtualraceresult SET coursecompleted = 0, duration = "{duration}", distance = {distance}, workoutid = {workoutid}, startsecond = {startsecond}, endsecond = {endsecond}, points={points} WHERE id={recordid}'.format(
|
||||
recordid=recordid,
|
||||
duration=totaltime_sec_to_string(0),
|
||||
distance=0),
|
||||
points=0,
|
||||
workoutid=workoutid,
|
||||
startsecond=startsecond,
|
||||
endsecond=endsecond,
|
||||
)
|
||||
|
||||
if mode == 'coursetest':
|
||||
query = 'UPDATE rowers_coursetestresult SET coursecompleted = 0, duration = "{duration}", distance = {distance}, workoutid = {workoutid}, startsecond = {startsecond}, endsecond = {endsecond}, points={points} WHERE id={recordid}'.format(
|
||||
recordid=recordid,
|
||||
duration=totaltime_sec_to_string(0),
|
||||
distance=0,
|
||||
points=0,
|
||||
workoutid=workoutid,
|
||||
startsecond=startsecond,
|
||||
endsecond=endsecond,
|
||||
)
|
||||
|
||||
|
||||
with engine.connect() as conn, conn.begin():
|
||||
result = conn.execute(query)
|
||||
|
||||
conn.close()
|
||||
engine.dispose()
|
||||
|
||||
# send email
|
||||
handle_send_email_coursefail(
|
||||
useremail,userfirstname,
|
||||
)
|
||||
|
||||
return 2
|
||||
|
||||
return 0
|
||||
@@ -1118,6 +1164,29 @@ def handle_sendemail_raceregistration(
|
||||
|
||||
return 1
|
||||
|
||||
def handle_sendemail_coursefail(
|
||||
useremail, username, **kwargs):
|
||||
|
||||
if 'debug' in kwargs:
|
||||
debug = kwargs['debug']
|
||||
else:
|
||||
debug = True
|
||||
|
||||
subject = "The validation of your course has failed"
|
||||
|
||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||
|
||||
d = {
|
||||
'username':username,
|
||||
}
|
||||
|
||||
res = send_template_email(from_email,[useremail],
|
||||
subject,
|
||||
'trajectoryfailemail.html',
|
||||
d,**kwargs)
|
||||
|
||||
return 1
|
||||
|
||||
@app.task
|
||||
def handle_sendemail_optout(
|
||||
useremail, username, registeredname, racename, raceid, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user