Private
Public Access
1
0

seems to be complete now

This commit is contained in:
Sander Roosendaal
2020-06-21 16:27:41 +02:00
parent add55993ba
commit 37f977a187
5 changed files with 106 additions and 26 deletions

View File

@@ -437,8 +437,12 @@ class UploadOptionsForm(forms.Form):
else: else:
registrations = IndoorVirtualRaceResult.objects.filter(race=therace,userid=r.id) registrations = IndoorVirtualRaceResult.objects.filter(race=therace,userid=r.id)
choices = [(r.id,str(r)) for r in registrations] if registrations.count()==0:
choices = [(0,'---')]+choices race = VirtualRace.objects.get(id=raceid)
choices = [(-int(raceid),race.name)]
else:
choices = [(r.id,str(r)) for r in registrations]
choices = choices+[(0,'---')]
if races: if races:
self.fields['submitrace'].choices = choices self.fields['submitrace'].choices = choices

View File

@@ -1041,8 +1041,8 @@ def race_can_edit(r,race):
return False return False
def race_can_submit(r,race): def race_can_submit(r,race):
if r not in race.rower.all(): #if r not in race.rower.all():
return False # return False
start_time = race.start_time start_time = race.start_time
start_date = race.startdate start_date = race.startdate
@@ -1451,12 +1451,34 @@ def add_workout_indoorrace(ws,race,r,recordid=0,doregister=False):
else: else:
age = None age = None
record = IndoorVirtualRaceResult.objects.get( try:
userid=r.id, record = IndoorVirtualRaceResult.objects.get(
race=race, userid=r.id,
id=recordid race=race,
) id=recordid
)
except IndoorVirtualRaceResult.DoesNotExist:
if doregister:
hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,initialcategory = default_class(r,ws[0],race)
if hasinitial:
record = IndoorVirtualRaceResult(
userid = r.id,
username = r.user.first_name+' '+r.user.last_name,
weightcategory=weightclass,
adaptiveclass=adaptiveclass,
race=race,
boatclass=boatclass,
sex=sex,
age = age,
entrycategory=initialcategory,
)
record.save()
else:
errors.append("Unable to find a suitable start category")
return result,comments,errors,0
else:
errors.append("Couldn't find this entry")
return result,comments,errors,0
records = IndoorVirtualRaceResult.objects.filter( records = IndoorVirtualRaceResult.objects.filter(
userid=r.id, userid=r.id,
@@ -1466,11 +1488,8 @@ def add_workout_indoorrace(ws,race,r,recordid=0,doregister=False):
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 race.sessionmode == 'distance':
@@ -1584,11 +1603,35 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0,doregister=False):
else: else:
age = None age = None
record = VirtualRaceResult.objects.get( try:
userid=r.id, record = VirtualRaceResult.objects.get(
race=race, userid=r.id,
id=recordid race=race,
) id=recordid
)
except VirtualRaceResult.DoesNotExist:
if doregister:
hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,initialcategory = default_class(r,ws[0],race)
if hasinitial:
record = VirtualRaceResult(
userid = r.id,
username = r.user.first_name+' '+r.user.last_name,
weightcategory=weightclass,
adaptiveclass=adaptiveclass,
race=race,
boatclass=boatclass,
boattype=boattype,
sex=sex,
age = age,
entrycategory=initialcategory,
)
record.save()
else:
errors.append("Unable to find a suitable start category")
return result,comments,errors,0
else:
errors.append("Couldn't find this entry")
return result,comments,errors,0
records = VirtualRaceResult.objects.filter( records = VirtualRaceResult.objects.filter(
userid=r.id, userid=r.id,
@@ -1656,6 +1699,8 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0,doregister=False):
referencespeed=record.referencespeed,coursedistance=race.course.distance referencespeed=record.referencespeed,coursedistance=race.course.distance
) )
comments.append('We are now checking adherence to the race course. This may take a few minutes to complete')
add_workouts_plannedsession(ws,race,r) add_workouts_plannedsession(ws,race,r)

View File

@@ -163,6 +163,7 @@
Registered users of rowsandall.com can participate in this challenge. Registered users of rowsandall.com can participate in this challenge.
Participation is free, unless specified differently in the race comment above. Participation is free, unless specified differently in the race comment above.
{% if race.sessiontype == 'race' %} {% if race.sessiontype == 'race' %}
Register to let others know you plan to do this challenge:
<a href="/rowers/virtualevent/{{ race.id }}/register"><h3>Register</h3></a> <a href="/rowers/virtualevent/{{ race.id }}/register"><h3>Register</h3></a>
{% else %} {% else %}
<a href="/rowers/virtualevent/{{ race.id }}/registerindoor"><h3>Register</h3></a> <a href="/rowers/virtualevent/{{ race.id }}/registerindoor"><h3>Register</h3></a>
@@ -183,6 +184,8 @@
{% for button in buttons %} {% for button in buttons %}
{% if button == 'registerbutton' %} {% if button == 'registerbutton' %}
<p> <p>
Register to let others know you plan to do this challenge. This also give you the option to
select your entry category:
{% if race.sessiontype == 'race' %} {% if race.sessiontype == 'race' %}
<a href="/rowers/virtualevent/{{ race.id }}/register"><h3>Register</h3></a> <a href="/rowers/virtualevent/{{ race.id }}/register"><h3>Register</h3></a>
{% else %} {% else %}

View File

@@ -746,6 +746,7 @@ def virtualevent_disqualify_view(request,id=0,recordid=0):
r = getrower(request.user) r = getrower(request.user)
race = get_object_or_404(VirtualRace,pk=id) race = get_object_or_404(VirtualRace,pk=id)
raceid = race.id
if race.sessiontype == 'race': if race.sessiontype == 'race':
@@ -2810,6 +2811,29 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0):
race=race race=race
) )
if records.count() == 0:
hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,initialcategory = default_class(r,None,race)
if not hasinitial:
messages.error(request,"Sorry, you have to register first")
url = reverse('virtualevent_view',
kwargs = {
'id':id,
})
return HttpResponseRedirect(url)
record = resultobj(
userid = r.id,
username = r.user.first_name+' '+r.user.last_name,
weightcategory=weightclass,
adaptiveclass=adaptiveclass,
race=race,
boatclass=boatclass,
sex=sex,
age=calculate_age(r.birthdate),
entrycategory=initialcategory,
)
record.save()
records = [record]
entrychoices = [] entrychoices = []

View File

@@ -5114,11 +5114,10 @@ def workout_upload_view(request,
messages.error(request,message) messages.error(request,message)
if int(registrationid) < 0: if int(registrationid) < 0:
race = VirtualRace.Objects.get(id=-int(registrationid)) race = VirtualRace.objects.get(id=-int(registrationid))
if race.sessiontype == 'race': if race.sessiontype == 'race':
race = registrations[0].race
result,comments,errors,jobid = add_workout_race( result,comments,errors,jobid = add_workout_race(
[w], race,r, [w], race,r,doregister=True,
) )
if result: if result:
messages.info( messages.info(
@@ -5130,9 +5129,8 @@ def workout_upload_view(request,
for er in errors: for er in errors:
messages.error(request,er) messages.error(request,er)
elif race.sessiontype == 'indoorrace': elif race.sessiontype == 'indoorrace':
race = registrations[0].race
result,comments,errors,jobid = add_workout_indoorrace( result,comments,errors,jobid = add_workout_indoorrace(
[w],race,r, [w],race,r,doregister=True,
) )
if result: if result:
@@ -5200,11 +5198,17 @@ def workout_upload_view(request,
if landingpage != 'workout_upload_view': if registrationid != 0:
url = reverse('virtualevent_view',
kwargs = {
'id':race.id,
})
elif landingpage != 'workout_upload_view':
url = reverse(landingpage, url = reverse(landingpage,
kwargs = { kwargs = {
'id':encoder.encode_hex(w.id), 'id':encoder.encode_hex(w.id),
}) })
else: else:
url = reverse(landingpage) url = reverse(landingpage)