adding categories to indoor races
This commit is contained in:
@@ -1553,7 +1553,7 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0):
|
||||
|
||||
job = myqueue(queue,handle_check_race_course,ws[0].csvfilename,
|
||||
ws[0].id,race.course.id,record.id,splitsecond=splitsecond,
|
||||
referencespeed=record.referencespeed)
|
||||
referencespeed=record.referencespeed,coursedistance=race.course.distance)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{% for record in records %}
|
||||
{% if record.userid == request.user.rower.id %}
|
||||
{% if record.userid == request.user.rower.id and forloop.counter == 1 %}
|
||||
{% if race.sessiontype == 'race' %}
|
||||
{% if record.emailnotifications %}
|
||||
<a href="/rowers/raceregistration/togglenotification/{{ race.id }}">
|
||||
|
||||
@@ -1422,6 +1422,12 @@ def virtualevent_addboat_view(request,id=0):
|
||||
except VirtualRace.DoesNotExist:
|
||||
raise Http404("Virtual Challenge does not exist")
|
||||
|
||||
categories = None
|
||||
if race.coursestandards is not None:
|
||||
categories = CourseStandard.objects.filter(
|
||||
standardcollection=race.coursestandards).order_by("name")
|
||||
|
||||
|
||||
if not race_can_adddiscipline(r,race):
|
||||
messages.error(request,"You cannot register for this race")
|
||||
|
||||
@@ -1445,7 +1451,7 @@ def virtualevent_addboat_view(request,id=0):
|
||||
# we're still here
|
||||
if request.method == 'POST':
|
||||
# process form
|
||||
form = VirtualRaceResultForm(request.POST)
|
||||
form = VirtualRaceResultForm(request.POST,categories=categories)
|
||||
if form.is_valid():
|
||||
cd = form.cleaned_data
|
||||
teamname = cd['teamname']
|
||||
@@ -1467,7 +1473,7 @@ def virtualevent_addboat_view(request,id=0):
|
||||
if sex == 'not specified':
|
||||
sex = 'male'
|
||||
|
||||
if boattype in boattypes and boatclass in boatclasses:
|
||||
if boattype in boattypes and boatclass in boatclasses and race.coursestandards is None:
|
||||
# check if different sexes
|
||||
therecords = records.filter(
|
||||
boattype=boattype,
|
||||
@@ -1488,6 +1494,49 @@ def virtualevent_addboat_view(request,id=0):
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
coursestandard = None
|
||||
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',
|
||||
kwargs = {
|
||||
'id': race.id
|
||||
}
|
||||
)
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
referencespeed = coursestandard.referencespeed
|
||||
boattype = coursestandard.boattype
|
||||
boatclass = coursestandard.boatclass
|
||||
weightcategory = coursestandard.weightclass
|
||||
adaptiveclass = coursestandard.adaptiveclass
|
||||
skillclass = coursestandard.skillclass
|
||||
|
||||
returnurl = reverse(virtualevent_register_view,
|
||||
kwargs={'id':race.id})
|
||||
|
||||
if age < coursestandard.agemin:
|
||||
messages.error(request,'You are younger than the minimum age for this group')
|
||||
return HttpResponseRedirect(returnurl)
|
||||
|
||||
if age > coursestandard.agemax:
|
||||
messages.error(request,'You are older than the maximum age for this group')
|
||||
return HttpResponseRedirect(returnurl)
|
||||
|
||||
if sex == 'male' and coursestandard.sex != 'male':
|
||||
messages.error(request,'Men are not allowed to enter this category')
|
||||
return HttpResponseRedirect(returnurl)
|
||||
|
||||
if sex == 'mixed' and coursestandard.sex not in ['mixed','male']:
|
||||
messages.error(request,'Mixed crews are not allowed to enter this category')
|
||||
return HttpResponseRedirect(returnurl)
|
||||
|
||||
|
||||
record = VirtualRaceResult(
|
||||
userid=r.id,
|
||||
teamname=teamname,
|
||||
@@ -1502,8 +1551,10 @@ def virtualevent_addboat_view(request,id=0):
|
||||
boattype=boattype,
|
||||
boatclass=boatclass,
|
||||
coursecompleted=False,
|
||||
referencespeed=referencespeed,
|
||||
entrycategory=coursestandard,
|
||||
sex=sex,
|
||||
age=age
|
||||
age=age,
|
||||
)
|
||||
|
||||
record.save()
|
||||
@@ -1840,6 +1891,11 @@ def indoorvirtualevent_register_view(request,id=0):
|
||||
except VirtualRace.DoesNotExist:
|
||||
raise Http404("Virtual Challenge does not exist")
|
||||
|
||||
categories = None
|
||||
if race.coursestandards is not None:
|
||||
categories = CourseStandard.objects.filter(
|
||||
standardcollection=race.coursestandards).order_by("name")
|
||||
|
||||
if not race_can_register(r,race):
|
||||
messages.error(request,"You cannot register for this race")
|
||||
|
||||
@@ -1853,7 +1909,7 @@ def indoorvirtualevent_register_view(request,id=0):
|
||||
# we're still here
|
||||
if request.method == 'POST':
|
||||
# process form
|
||||
form = IndoorVirtualRaceResultForm(request.POST)
|
||||
form = IndoorVirtualRaceResultForm(request.POST,categories=categories)
|
||||
if form.is_valid():
|
||||
cd = form.cleaned_data
|
||||
teamname = cd['teamname']
|
||||
@@ -1871,6 +1927,38 @@ def indoorvirtualevent_register_view(request,id=0):
|
||||
if sex == 'not specified':
|
||||
sex = 'male'
|
||||
|
||||
coursestandard = None
|
||||
referencespeed = 5.0
|
||||
|
||||
if race.coursestandards is not None:
|
||||
coursestandard = cd['entrycategory']
|
||||
referencespeed = coursestandard.referencespeed
|
||||
boatclass = coursestandard.boatclass
|
||||
weightcategory = coursestandard.weightclass
|
||||
adaptiveclass = coursestandard.adaptiveclass
|
||||
skillclass = coursestandard.skillclass
|
||||
|
||||
returnurl = reverse(virtualevent_register_view,
|
||||
kwargs={'id':race.id})
|
||||
|
||||
if age < coursestandard.agemin:
|
||||
messages.error(request,'You are younger than the minimum age for this group')
|
||||
return HttpResponseRedirect(returnurl)
|
||||
|
||||
if age > coursestandard.agemax:
|
||||
messages.error(request,'You are older than the maximum age for this group')
|
||||
return HttpResponseRedirect(returnurl)
|
||||
|
||||
if sex == 'male' and coursestandard.sex != 'male':
|
||||
messages.error(request,'Men are not allowed to enter this category')
|
||||
return HttpResponseRedirect(returnurl)
|
||||
|
||||
if sex == 'mixed' and coursestandard.sex not in ['mixed','male']:
|
||||
messages.error(request,'Mixed crews are not allowed to enter this category')
|
||||
return HttpResponseRedirect(returnurl)
|
||||
|
||||
|
||||
|
||||
record = IndoorVirtualRaceResult(
|
||||
userid=r.id,
|
||||
teamname=teamname,
|
||||
@@ -1885,7 +1973,9 @@ def indoorvirtualevent_register_view(request,id=0):
|
||||
boatclass=boatclass,
|
||||
coursecompleted=False,
|
||||
sex=sex,
|
||||
age=age
|
||||
age=age,
|
||||
entrycategory=coursestandard,
|
||||
referencespeed=referencespeed
|
||||
)
|
||||
|
||||
record.save()
|
||||
|
||||
Reference in New Issue
Block a user