add boat for virutal race improvements
This commit is contained in:
@@ -438,7 +438,7 @@ def add_workouts_plannedsession(ws,ps,r):
|
|||||||
ids = [w.id for w in wold] + [w.id for w in ws]
|
ids = [w.id for w in wold] + [w.id for w in ws]
|
||||||
ids = list(set(ids))
|
ids = list(set(ids))
|
||||||
|
|
||||||
if len(ids)>1 and ps.sessiontype in ['test','coursetest','race']:
|
if len(ids)>1 and ps.sessiontype in ['test','coursetest','race','fastest_time','fastest_distance']:
|
||||||
errors.append('For tests, you can only attach one workout')
|
errors.append('For tests, you can only attach one workout')
|
||||||
return result,comments,errors
|
return result,comments,errors
|
||||||
|
|
||||||
@@ -1199,7 +1199,7 @@ def race_rower_status(r,race):
|
|||||||
has_registered = False
|
has_registered = False
|
||||||
is_complete = False
|
is_complete = False
|
||||||
|
|
||||||
if race.sessiontype == 'race':
|
if race.sessiontype in ['race']:
|
||||||
resultobj = VirtualRaceResult
|
resultobj = VirtualRaceResult
|
||||||
else:
|
else:
|
||||||
resultobj = IndoorVirtualRaceResult
|
resultobj = IndoorVirtualRaceResult
|
||||||
@@ -1308,10 +1308,15 @@ def race_can_resubmit(r,race):
|
|||||||
|
|
||||||
def race_can_adddiscipline(r,race):
|
def race_can_adddiscipline(r,race):
|
||||||
|
|
||||||
if race.sessiontype != 'race':
|
if race.sessiontype not in ['race','fastest_time','fastest_distance']:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
records = VirtualRaceResult.objects.filter(
|
if race.sessiontype == ['race']:
|
||||||
|
resultobj = VirtualRaceResult
|
||||||
|
else:
|
||||||
|
resultobj = IndoorVirtualRaceResult
|
||||||
|
|
||||||
|
records = resultobj.objects.filter(
|
||||||
userid=r.id,
|
userid=r.id,
|
||||||
race=race)
|
race=race)
|
||||||
|
|
||||||
@@ -1319,6 +1324,7 @@ def race_can_adddiscipline(r,race):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
start_time = race.start_time
|
start_time = race.start_time
|
||||||
start_date = race.startdate
|
start_date = race.startdate
|
||||||
startdatetime = datetime.combine(start_date,start_time)
|
startdatetime = datetime.combine(start_date,start_time)
|
||||||
@@ -1341,7 +1347,7 @@ def race_can_adddiscipline(r,race):
|
|||||||
|
|
||||||
|
|
||||||
def race_can_withdraw(r,race):
|
def race_can_withdraw(r,race):
|
||||||
if race.sessiontype == 'race':
|
if race.sessiontype in ['race']:
|
||||||
recordobj = VirtualRaceResult
|
recordobj = VirtualRaceResult
|
||||||
else:
|
else:
|
||||||
recordobj = IndoorVirtualRaceResult
|
recordobj = IndoorVirtualRaceResult
|
||||||
@@ -1500,7 +1506,7 @@ def email_submit_race(r,race,workoutid):
|
|||||||
|
|
||||||
|
|
||||||
def race_can_register(r,race):
|
def race_can_register(r,race):
|
||||||
if race.sessiontype == 'race':
|
if race.sessiontype in ['race']:
|
||||||
recordobj = VirtualRaceResult
|
recordobj = VirtualRaceResult
|
||||||
else:
|
else:
|
||||||
recordobj = IndoorVirtualRaceResult
|
recordobj = IndoorVirtualRaceResult
|
||||||
@@ -1537,7 +1543,7 @@ def add_rower_race(r,race):
|
|||||||
def remove_rower_race(r,race,recordid=None):
|
def remove_rower_race(r,race,recordid=None):
|
||||||
race.rower.remove(r)
|
race.rower.remove(r)
|
||||||
|
|
||||||
if race.sessiontype == 'race':
|
if race.sessiontype in ['race']:
|
||||||
recordobj = VirtualRaceResult
|
recordobj = VirtualRaceResult
|
||||||
else:
|
else:
|
||||||
recordobj = IndoorVirtualRaceResult
|
recordobj = IndoorVirtualRaceResult
|
||||||
@@ -1835,7 +1841,7 @@ def add_workout_indoorrace(ws,race,r,recordid=0,doregister=False):
|
|||||||
ids = [w.id for w in ws]
|
ids = [w.id for w in ws]
|
||||||
ids = list(set(ids))
|
ids = list(set(ids))
|
||||||
|
|
||||||
if len(ids)>1 and race.sessiontype in ['test','coursetest','race','indoorrace']:
|
if len(ids)>1 and race.sessiontype in ['test','coursetest','race','indoorrace','fastest_time','fastest_distance']:
|
||||||
errors.append('For tests, you can only attach one workout')
|
errors.append('For tests, you can only attach one workout')
|
||||||
return result,comments,errors,0
|
return result,comments,errors,0
|
||||||
|
|
||||||
@@ -1983,7 +1989,7 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0,doregister=False):
|
|||||||
ids = [w.id for w in ws]
|
ids = [w.id for w in ws]
|
||||||
ids = list(set(ids))
|
ids = list(set(ids))
|
||||||
|
|
||||||
if len(ids)>1 and race.sessiontype in ['test','coursetest','race']:
|
if len(ids)>1 and race.sessiontype in ['test','coursetest','race','fastest_time','fastest_distance']:
|
||||||
errors.append('For tests, you can only attach one workout')
|
errors.append('For tests, you can only attach one workout')
|
||||||
return result,comments,errors,0
|
return result,comments,errors,0
|
||||||
|
|
||||||
|
|||||||
@@ -1714,6 +1714,11 @@ def virtualevent_addboat_view(request,id=0):
|
|||||||
except VirtualRace.DoesNotExist:
|
except VirtualRace.DoesNotExist:
|
||||||
raise Http404("Virtual Challenge does not exist")
|
raise Http404("Virtual Challenge does not exist")
|
||||||
|
|
||||||
|
if race.sessiontype in ['race']:
|
||||||
|
resultobj = VirtualRaceResult
|
||||||
|
else:
|
||||||
|
resultobj = IndoorVirtualRaceResult
|
||||||
|
|
||||||
categories = None
|
categories = None
|
||||||
hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,referencespeed,initialcategory = default_class(r,None,race)
|
hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,referencespeed,initialcategory = default_class(r,None,race)
|
||||||
if race.coursestandards is not None:
|
if race.coursestandards is not None:
|
||||||
@@ -1731,11 +1736,12 @@ def virtualevent_addboat_view(request,id=0):
|
|||||||
|
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
records = VirtualRaceResult.objects.filter(
|
records = resultobj.objects.filter(
|
||||||
userid = r.id,
|
userid = r.id,
|
||||||
race = race
|
race = race
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
boattypes = [record.boattype for record in records]
|
boattypes = [record.boattype for record in records]
|
||||||
boatclasses = [record.boatclass for record in records]
|
boatclasses = [record.boatclass for record in records]
|
||||||
allowedboats = tuple([ type for type in mytypes.boattypes if type[0] not in boattypes] )
|
allowedboats = tuple([ type for type in mytypes.boattypes if type[0] not in boattypes] )
|
||||||
@@ -1757,8 +1763,6 @@ def virtualevent_addboat_view(request,id=0):
|
|||||||
acceptsocialmedia = cd['acceptsocialmedia']
|
acceptsocialmedia = cd['acceptsocialmedia']
|
||||||
|
|
||||||
sex = r.sex
|
sex = r.sex
|
||||||
if mix:
|
|
||||||
sex = 'mixed'
|
|
||||||
|
|
||||||
if boattype == '1x' and r.birthdate:
|
if boattype == '1x' and r.birthdate:
|
||||||
age = calculate_age(r.birthdate)
|
age = calculate_age(r.birthdate)
|
||||||
@@ -1767,6 +1771,10 @@ def virtualevent_addboat_view(request,id=0):
|
|||||||
if sex == 'not specified':
|
if sex == 'not specified':
|
||||||
sex = 'male'
|
sex = 'male'
|
||||||
|
|
||||||
|
if mix:
|
||||||
|
sex = 'mixed'
|
||||||
|
|
||||||
|
|
||||||
if boattype in boattypes and boatclass in boatclasses and race.coursestandards is None:
|
if boattype in boattypes and boatclass in boatclasses and race.coursestandards is None:
|
||||||
# check if different sexes
|
# check if different sexes
|
||||||
therecords = records.filter(
|
therecords = records.filter(
|
||||||
@@ -1792,8 +1800,11 @@ def virtualevent_addboat_view(request,id=0):
|
|||||||
referencespeed = 5.0
|
referencespeed = 5.0
|
||||||
|
|
||||||
if race.coursestandards is not None:
|
if race.coursestandards is not None:
|
||||||
|
|
||||||
coursestandard = cd['entrycategory']
|
coursestandard = cd['entrycategory']
|
||||||
|
|
||||||
thegroups = [record.entrycategory for record in records]
|
thegroups = [record.entrycategory for record in records]
|
||||||
|
|
||||||
if coursestandard in thegroups:
|
if coursestandard in thegroups:
|
||||||
messages.error(request,"You have already registered in that group")
|
messages.error(request,"You have already registered in that group")
|
||||||
url = reverse('virtualevent_view',
|
url = reverse('virtualevent_view',
|
||||||
@@ -1831,7 +1842,7 @@ def virtualevent_addboat_view(request,id=0):
|
|||||||
return HttpResponseRedirect(returnurl)
|
return HttpResponseRedirect(returnurl)
|
||||||
|
|
||||||
|
|
||||||
record = VirtualRaceResult(
|
record = resultobj(
|
||||||
userid=r.id,
|
userid=r.id,
|
||||||
teamname=teamname,
|
teamname=teamname,
|
||||||
race=race,
|
race=race,
|
||||||
@@ -1872,7 +1883,7 @@ def virtualevent_addboat_view(request,id=0):
|
|||||||
"You have successfully registered for this race. Good luck!"
|
"You have successfully registered for this race. Good luck!"
|
||||||
)
|
)
|
||||||
|
|
||||||
otherrecords = VirtualRaceResult.objects.filter(
|
otherrecords = resultobj.objects.filter(
|
||||||
race = race).exclude(userid = r.id)
|
race = race).exclude(userid = r.id)
|
||||||
|
|
||||||
for otherrecord in otherrecords:
|
for otherrecord in otherrecords:
|
||||||
@@ -2001,6 +2012,7 @@ def virtualevent_register_view(request,id=0):
|
|||||||
except VirtualRace.DoesNotExist:
|
except VirtualRace.DoesNotExist:
|
||||||
raise Http404("Virtual Challenge does not exist")
|
raise Http404("Virtual Challenge does not exist")
|
||||||
|
|
||||||
|
|
||||||
categories = None
|
categories = None
|
||||||
hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,referencespeed,initialcategory = default_class(r,None,race)
|
hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,referencespeed,initialcategory = default_class(r,None,race)
|
||||||
|
|
||||||
@@ -2040,8 +2052,7 @@ def virtualevent_register_view(request,id=0):
|
|||||||
acceptsocialmedia = cd['acceptsocialmedia']
|
acceptsocialmedia = cd['acceptsocialmedia']
|
||||||
|
|
||||||
sex = r.sex
|
sex = r.sex
|
||||||
if mix:
|
|
||||||
sex = 'mixed'
|
|
||||||
|
|
||||||
if boattype == '1x' and r.birthdate:
|
if boattype == '1x' and r.birthdate:
|
||||||
age = calculate_age(r.birthdate)
|
age = calculate_age(r.birthdate)
|
||||||
@@ -2050,6 +2061,9 @@ def virtualevent_register_view(request,id=0):
|
|||||||
if sex == 'not specified':
|
if sex == 'not specified':
|
||||||
sex = 'male'
|
sex = 'male'
|
||||||
|
|
||||||
|
if mix:
|
||||||
|
sex = 'mixed'
|
||||||
|
|
||||||
|
|
||||||
coursestandard = None
|
coursestandard = None
|
||||||
referencespeed = 5.0
|
referencespeed = 5.0
|
||||||
@@ -2124,7 +2138,7 @@ def virtualevent_register_view(request,id=0):
|
|||||||
for f in myfollows:
|
for f in myfollows:
|
||||||
f.delete()
|
f.delete()
|
||||||
|
|
||||||
otherrecords = VirtualRaceResult.objects.filter(
|
otherrecords = resultobj.objects.filter(
|
||||||
race = race).exclude(userid = r.id)
|
race = race).exclude(userid = r.id)
|
||||||
|
|
||||||
for otherrecord in otherrecords:
|
for otherrecord in otherrecords:
|
||||||
|
|||||||
Reference in New Issue
Block a user