more robust race form
This commit is contained in:
@@ -712,7 +712,7 @@ def remove_rower_race(r,race):
|
||||
return 1
|
||||
|
||||
# Low Level functions - to be called by higher level methods
|
||||
def add_workout_race(ws,race,r):
|
||||
def add_workout_race(ws,race,r,splitsecond=0):
|
||||
result = 0
|
||||
comments = []
|
||||
errors = []
|
||||
@@ -750,6 +750,29 @@ def add_workout_race(ws,race,r):
|
||||
errors.append('For tests, you can only attach one workout')
|
||||
return result,comments,errors,0
|
||||
|
||||
|
||||
|
||||
username = r.user.first_name+' '+r.user.last_name
|
||||
if r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
else:
|
||||
age = None
|
||||
|
||||
records = VirtualRaceResult.objects.filter(
|
||||
userid=r.id,
|
||||
race=race
|
||||
)
|
||||
|
||||
record = records[0]
|
||||
|
||||
if ws[0].boattype != record.boattype:
|
||||
errors.append('Your workout boat type did not match the boat type you registered')
|
||||
return 0,comments,errors,0
|
||||
|
||||
if ws[0].weightcategory != record.weightcategory:
|
||||
errors.append('Your workout weight category did not match the weight category you registered')
|
||||
return 0,comments, errors,0
|
||||
|
||||
# start adding sessions
|
||||
for w in ws:
|
||||
if w.startdatetime>=startdatetime and w.startdatetime<=enddatetime:
|
||||
@@ -762,30 +785,9 @@ def add_workout_race(ws,race,r):
|
||||
return result,comments,errors,0
|
||||
|
||||
if result>0:
|
||||
username = r.user.first_name+' '+r.user.last_name
|
||||
if r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
else:
|
||||
age = None
|
||||
|
||||
records = VirtualRaceResult.objects.filter(
|
||||
userid=r.id,
|
||||
race=race
|
||||
)
|
||||
|
||||
record = records[0]
|
||||
|
||||
if ws[0].boattype != record.boattype:
|
||||
errors.append('Your workout boat type did not match the boat type you registered')
|
||||
return result,comments,errors,0
|
||||
|
||||
if ws[0].weightcategory != record.weightcategory:
|
||||
errors.append('Your workout weight category did not match the weight category you registered')
|
||||
return result,comments, errors,0
|
||||
|
||||
|
||||
job = myqueue(queue,handle_check_race_course,ws[0].csvfilename,
|
||||
ws[0].id,race.course.id,record.id)
|
||||
ws[0].id,race.course.id,record.id,splitsecond=splitsecond)
|
||||
|
||||
add_workouts_plannedsession(ws,race,r)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user