add boat for virutal race improvements
This commit is contained in:
@@ -1714,6 +1714,11 @@ def virtualevent_addboat_view(request,id=0):
|
||||
except VirtualRace.DoesNotExist:
|
||||
raise Http404("Virtual Challenge does not exist")
|
||||
|
||||
if race.sessiontype in ['race']:
|
||||
resultobj = VirtualRaceResult
|
||||
else:
|
||||
resultobj = IndoorVirtualRaceResult
|
||||
|
||||
categories = None
|
||||
hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,referencespeed,initialcategory = default_class(r,None,race)
|
||||
if race.coursestandards is not None:
|
||||
@@ -1731,11 +1736,12 @@ def virtualevent_addboat_view(request,id=0):
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
records = VirtualRaceResult.objects.filter(
|
||||
records = resultobj.objects.filter(
|
||||
userid = r.id,
|
||||
race = race
|
||||
)
|
||||
|
||||
|
||||
boattypes = [record.boattype 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] )
|
||||
@@ -1757,8 +1763,6 @@ def virtualevent_addboat_view(request,id=0):
|
||||
acceptsocialmedia = cd['acceptsocialmedia']
|
||||
|
||||
sex = r.sex
|
||||
if mix:
|
||||
sex = 'mixed'
|
||||
|
||||
if boattype == '1x' and r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
@@ -1767,6 +1771,10 @@ def virtualevent_addboat_view(request,id=0):
|
||||
if sex == 'not specified':
|
||||
sex = 'male'
|
||||
|
||||
if mix:
|
||||
sex = 'mixed'
|
||||
|
||||
|
||||
if boattype in boattypes and boatclass in boatclasses and race.coursestandards is None:
|
||||
# check if different sexes
|
||||
therecords = records.filter(
|
||||
@@ -1792,8 +1800,11 @@ def virtualevent_addboat_view(request,id=0):
|
||||
referencespeed = 5.0
|
||||
|
||||
if race.coursestandards is not None:
|
||||
|
||||
coursestandard = cd['entrycategory']
|
||||
|
||||
thegroups = [record.entrycategory for record in records]
|
||||
|
||||
if coursestandard in thegroups:
|
||||
messages.error(request,"You have already registered in that group")
|
||||
url = reverse('virtualevent_view',
|
||||
@@ -1831,7 +1842,7 @@ def virtualevent_addboat_view(request,id=0):
|
||||
return HttpResponseRedirect(returnurl)
|
||||
|
||||
|
||||
record = VirtualRaceResult(
|
||||
record = resultobj(
|
||||
userid=r.id,
|
||||
teamname=teamname,
|
||||
race=race,
|
||||
@@ -1872,7 +1883,7 @@ def virtualevent_addboat_view(request,id=0):
|
||||
"You have successfully registered for this race. Good luck!"
|
||||
)
|
||||
|
||||
otherrecords = VirtualRaceResult.objects.filter(
|
||||
otherrecords = resultobj.objects.filter(
|
||||
race = race).exclude(userid = r.id)
|
||||
|
||||
for otherrecord in otherrecords:
|
||||
@@ -2001,6 +2012,7 @@ def virtualevent_register_view(request,id=0):
|
||||
except VirtualRace.DoesNotExist:
|
||||
raise Http404("Virtual Challenge does not exist")
|
||||
|
||||
|
||||
categories = None
|
||||
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']
|
||||
|
||||
sex = r.sex
|
||||
if mix:
|
||||
sex = 'mixed'
|
||||
|
||||
|
||||
if boattype == '1x' and r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
@@ -2050,6 +2061,9 @@ def virtualevent_register_view(request,id=0):
|
||||
if sex == 'not specified':
|
||||
sex = 'male'
|
||||
|
||||
if mix:
|
||||
sex = 'mixed'
|
||||
|
||||
|
||||
coursestandard = None
|
||||
referencespeed = 5.0
|
||||
@@ -2124,7 +2138,7 @@ def virtualevent_register_view(request,id=0):
|
||||
for f in myfollows:
|
||||
f.delete()
|
||||
|
||||
otherrecords = VirtualRaceResult.objects.filter(
|
||||
otherrecords = resultobj.objects.filter(
|
||||
race = race).exclude(userid = r.id)
|
||||
|
||||
for otherrecord in otherrecords:
|
||||
|
||||
Reference in New Issue
Block a user