better OTW uploading and submitting
This commit is contained in:
@@ -389,18 +389,26 @@ class UploadOptionsForm(forms.Form):
|
|||||||
super(UploadOptionsForm, self).__init__(*args, **kwargs)
|
super(UploadOptionsForm, self).__init__(*args, **kwargs)
|
||||||
r = Rower.objects.get(user=self.request.user)
|
r = Rower.objects.get(user=self.request.user)
|
||||||
races = VirtualRace.objects.filter(
|
races = VirtualRace.objects.filter(
|
||||||
registration_closure__gt=timezone.now(),
|
registration_closure__gt=timezone.now())
|
||||||
sessiontype='indoorrace')
|
|
||||||
registrations = IndoorVirtualRaceResult.objects.filter(
|
registrations = IndoorVirtualRaceResult.objects.filter(
|
||||||
race__in = races,
|
race__in = races,
|
||||||
userid = r.id)
|
userid = r.id)
|
||||||
|
|
||||||
|
registrations2 = VirtualRaceResult.objects.filter(
|
||||||
|
race__in = races,
|
||||||
|
userid = r.id,
|
||||||
|
)
|
||||||
|
|
||||||
raceids = [r.race.id for r in registrations]
|
raceids = [r.race.id for r in registrations]
|
||||||
|
raceids2 = [r.race.id for r in registrations2]
|
||||||
|
|
||||||
|
raceids = raceids+raceids2
|
||||||
|
|
||||||
races = VirtualRace.objects.filter(
|
races = VirtualRace.objects.filter(
|
||||||
id__in=raceids
|
id__in=raceids
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if races:
|
if races:
|
||||||
self.fields['submitrace'].queryset = races
|
self.fields['submitrace'].queryset = races
|
||||||
else:
|
else:
|
||||||
@@ -409,6 +417,8 @@ class UploadOptionsForm(forms.Form):
|
|||||||
if int(raceid) in raceids:
|
if int(raceid) in raceids:
|
||||||
self.fields['submitrace'].initial = VirtualRace.objects.get(id=raceid)
|
self.fields['submitrace'].initial = VirtualRace.objects.get(id=raceid)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# The form to indicate additional actions to be performed immediately
|
# The form to indicate additional actions to be performed immediately
|
||||||
# after a successful upload. This version allows the Team manager to select
|
# after a successful upload. This version allows the Team manager to select
|
||||||
# a team member
|
# a team member
|
||||||
|
|||||||
@@ -1472,7 +1472,7 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0):
|
|||||||
errors.append('For tests and training sessions, selected workouts must all be done on the same date')
|
errors.append('For tests and training sessions, selected workouts must all be done on the same date')
|
||||||
return result,comments,errors,0
|
return result,comments,errors,0
|
||||||
|
|
||||||
if ws.count()>1 and race.sessiontype == 'test':
|
if len(ws)>1 and race.sessiontype == 'test':
|
||||||
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
|
||||||
|
|
||||||
@@ -1553,6 +1553,8 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0):
|
|||||||
job = myqueue(queue,handle_check_race_course,ws[0].csvfilename,
|
job = myqueue(queue,handle_check_race_course,ws[0].csvfilename,
|
||||||
ws[0].id,race.course.id,record.id,splitsecond=splitsecond)
|
ws[0].id,race.course.id,record.id,splitsecond=splitsecond)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_workouts_plannedsession(ws,race,r)
|
add_workouts_plannedsession(ws,race,r)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
<i class="fas fa-file-plus fa-fw"></i> Submit Workout</a>
|
<i class="fas fa-file-plus fa-fw"></i> Submit Workout</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/rowers/workout/upload/">
|
<a href="/rowers/workout/upload/{{ race.id }}/">
|
||||||
<i class="fas fa-file-upload fa-fw"></i> Upload your Challenge result
|
<i class="fas fa-file-upload fa-fw"></i> Upload your Challenge result
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -4965,26 +4965,46 @@ def workout_upload_view(request,
|
|||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
|
|
||||||
if race and race_can_submit(r,race):
|
if race and race_can_submit(r,race):
|
||||||
records = IndoorVirtualRaceResult.objects.filter(
|
if race.sessiontype == 'indoorrace':
|
||||||
race=race,
|
records = IndoorVirtualRaceResult.objects.filter(
|
||||||
userid=r.id
|
race=race,
|
||||||
)
|
userid=r.id
|
||||||
|
|
||||||
if records:
|
|
||||||
|
|
||||||
result,comments,errors,jobid = add_workout_indoorrace(
|
|
||||||
[w],race,r,recordid=records[0].id
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if result:
|
if records:
|
||||||
messages.info(
|
|
||||||
request,
|
|
||||||
"We have submitted your workout to the race")
|
|
||||||
|
|
||||||
for c in comments:
|
result,comments,errors,jobid = add_workout_indoorrace(
|
||||||
messages.info(request,c)
|
[w],race,r,recordid=records[0].id
|
||||||
for er in errors:
|
)
|
||||||
messages.error(request,er)
|
|
||||||
|
if result:
|
||||||
|
messages.info(
|
||||||
|
request,
|
||||||
|
"We have submitted your workout to the race")
|
||||||
|
|
||||||
|
for c in comments:
|
||||||
|
messages.info(request,c)
|
||||||
|
for er in errors:
|
||||||
|
messages.error(request,er)
|
||||||
|
if race.sessiontype == 'race':
|
||||||
|
records = VirtualRaceResult.objects.filter(
|
||||||
|
race=race,userid=r.id
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if records:
|
||||||
|
result,comments,errors,jobid = add_workout_race(
|
||||||
|
[w], race,r,recordid=records[0].id
|
||||||
|
)
|
||||||
|
if result:
|
||||||
|
messages.info(
|
||||||
|
request,
|
||||||
|
"We have submitted your workout to the race")
|
||||||
|
|
||||||
|
for c in comments:
|
||||||
|
messages.info(request,c)
|
||||||
|
for er in errors:
|
||||||
|
messages.error(request,er)
|
||||||
|
|
||||||
|
|
||||||
if landingpage != 'workout_upload_view':
|
if landingpage != 'workout_upload_view':
|
||||||
|
|||||||
Reference in New Issue
Block a user