diff --git a/rowers/forms.py b/rowers/forms.py
index 694962b5..d3b23329 100644
--- a/rowers/forms.py
+++ b/rowers/forms.py
@@ -437,8 +437,12 @@ class UploadOptionsForm(forms.Form):
else:
registrations = IndoorVirtualRaceResult.objects.filter(race=therace,userid=r.id)
- choices = [(r.id,str(r)) for r in registrations]
- choices = [(0,'---')]+choices
+ if registrations.count()==0:
+ 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:
self.fields['submitrace'].choices = choices
diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py
index 93206cbe..92166a78 100644
--- a/rowers/plannedsessions.py
+++ b/rowers/plannedsessions.py
@@ -1041,8 +1041,8 @@ def race_can_edit(r,race):
return False
def race_can_submit(r,race):
- if r not in race.rower.all():
- return False
+ #if r not in race.rower.all():
+ # return False
start_time = race.start_time
start_date = race.startdate
@@ -1451,12 +1451,34 @@ def add_workout_indoorrace(ws,race,r,recordid=0,doregister=False):
else:
age = None
- record = IndoorVirtualRaceResult.objects.get(
- userid=r.id,
- race=race,
- id=recordid
- )
-
+ try:
+ record = IndoorVirtualRaceResult.objects.get(
+ userid=r.id,
+ 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(
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':
@@ -1584,11 +1603,35 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0,doregister=False):
else:
age = None
- record = VirtualRaceResult.objects.get(
- userid=r.id,
- race=race,
- id=recordid
- )
+ try:
+ record = VirtualRaceResult.objects.get(
+ userid=r.id,
+ 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(
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
)
+ 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)
diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html
index 26d16084..6decfc0c 100644
--- a/rowers/templates/virtualevent.html
+++ b/rowers/templates/virtualevent.html
@@ -163,6 +163,7 @@
Registered users of rowsandall.com can participate in this challenge.
Participation is free, unless specified differently in the race comment above.
{% if race.sessiontype == 'race' %}
+ Register to let others know you plan to do this challenge:
Register
{% else %}
Register
@@ -183,6 +184,8 @@
{% for button in buttons %}
{% if button == 'registerbutton' %}
+ 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' %}
Register
{% else %}
diff --git a/rowers/views/racesviews.py b/rowers/views/racesviews.py
index c2148ac0..93df6047 100644
--- a/rowers/views/racesviews.py
+++ b/rowers/views/racesviews.py
@@ -746,6 +746,7 @@ def virtualevent_disqualify_view(request,id=0,recordid=0):
r = getrower(request.user)
race = get_object_or_404(VirtualRace,pk=id)
+ raceid = race.id
if race.sessiontype == 'race':
@@ -2810,6 +2811,29 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0):
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 = []
diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py
index 79b8f1ea..914064b0 100644
--- a/rowers/views/workoutviews.py
+++ b/rowers/views/workoutviews.py
@@ -5114,11 +5114,10 @@ def workout_upload_view(request,
messages.error(request,message)
if int(registrationid) < 0:
- race = VirtualRace.Objects.get(id=-int(registrationid))
+ race = VirtualRace.objects.get(id=-int(registrationid))
if race.sessiontype == 'race':
- race = registrations[0].race
result,comments,errors,jobid = add_workout_race(
- [w], race,r,
+ [w], race,r,doregister=True,
)
if result:
messages.info(
@@ -5130,9 +5129,8 @@ def workout_upload_view(request,
for er in errors:
messages.error(request,er)
elif race.sessiontype == 'indoorrace':
- race = registrations[0].race
result,comments,errors,jobid = add_workout_indoorrace(
- [w],race,r,
+ [w],race,r,doregister=True,
)
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,
kwargs = {
'id':encoder.encode_hex(w.id),
})
+
else:
url = reverse(landingpage)