form initial now has better default initial
This commit is contained in:
@@ -45,7 +45,7 @@ from rowers.models import (
|
||||
GeoCourse, TrainingMicroCycle,TrainingMesoCycle,TrainingMacroCycle,
|
||||
TrainingPlan,PlannedSession,VirtualRaceResult,CourseTestResult,
|
||||
get_course_timezone, IndoorVirtualRaceResult,VirtualRace,createmacrofillers,
|
||||
createmesofillers,createmicrofillers,
|
||||
createmesofillers,createmicrofillers,CourseStandard,
|
||||
)
|
||||
|
||||
from rowers.courses import get_time_course
|
||||
@@ -1341,9 +1341,70 @@ def remove_rower_race(r,race,recordid=None):
|
||||
|
||||
return 1
|
||||
|
||||
def default_class(r,w,race):
|
||||
if r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
else:
|
||||
age = 25
|
||||
|
||||
sex = r.sex
|
||||
if sex=='not specified':
|
||||
sex='male'
|
||||
|
||||
if w is not None:
|
||||
boatclass = w.workouttype
|
||||
boattype = w.boattype
|
||||
|
||||
adaptiveclass = w.adaptiveclass
|
||||
weightclass = w.weightcategory
|
||||
else:
|
||||
if race.sessiontype == 'race':
|
||||
boatclass = 'water'
|
||||
else:
|
||||
boatclass = 'rower'
|
||||
boattype = '1x'
|
||||
adaptiveclass = 'None'
|
||||
weightclass = 'hwt'
|
||||
|
||||
if race.coursestandards:
|
||||
standards = CourseStandard.objects.filter(
|
||||
agemin__lt=age,agemax__gt=age,
|
||||
boatclass=boatclass,
|
||||
adaptiveclass=adaptiveclass,
|
||||
boattype=boattype,
|
||||
weightclass=weightclass
|
||||
).order_by("agemax","-agemin","boattype")
|
||||
|
||||
|
||||
if standards.count()==0:
|
||||
# omit weight
|
||||
standards = CourseStandard.objects.filter(agemin__lt=age,agemax__gt=age,
|
||||
boatclass=boatclass,
|
||||
adaptiveclass=adaptiveclass,
|
||||
boattype=boattype,
|
||||
)
|
||||
if standards.count()==0:
|
||||
standards = CourseStandard.objects.filter(agemin__lt=age,agemax__gt=age,
|
||||
boattype=boattype)
|
||||
if standards.count()==0:
|
||||
standards = CourseStandard.objects.filter(agemin__lt=age,agemax__gt=age)
|
||||
|
||||
if standards.count()==0:
|
||||
# boolean, boattype, boatclass, adaptiveclass, weightclass, sex, coursestandard,
|
||||
return False,'1x','water',None,'hwt','male',None
|
||||
|
||||
if standards.count()>0:
|
||||
# find optimum standard
|
||||
s = standards[0]
|
||||
return True,s.boattype,s.boatclass,s.adaptiveclass,s.weightclass,s.sex,s
|
||||
|
||||
# No Course Standard
|
||||
return True,boattype,boatclass,adaptiveclass,weightclass,sex,None
|
||||
|
||||
|
||||
|
||||
# Low Level functions - to be called by higher level methods
|
||||
def add_workout_indoorrace(ws,race,r,recordid=0):
|
||||
print('aap')
|
||||
def add_workout_indoorrace(ws,race,r,recordid=0,doregister=False):
|
||||
result = 0
|
||||
comments = []
|
||||
errors = []
|
||||
@@ -1403,11 +1464,14 @@ def add_workout_indoorrace(ws,race,r,recordid=0):
|
||||
workoutid = ws[0].id
|
||||
)
|
||||
|
||||
print(record,records)
|
||||
|
||||
if not record:
|
||||
|
||||
if not record and not doregister:
|
||||
errors.append("Couldn't find this entry")
|
||||
return result,comments,errors,0
|
||||
elif not record:
|
||||
pass
|
||||
|
||||
|
||||
if race.sessionmode == 'distance':
|
||||
if ws[0].distance != race.sessionvalue:
|
||||
@@ -1532,7 +1596,7 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0,doregister=False):
|
||||
workoutid = ws[0].id
|
||||
)
|
||||
|
||||
if not record:
|
||||
if not record and not doregister:
|
||||
errors.append("Couldn't find this entry")
|
||||
return result,comments,errors,0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user