working submission
This commit is contained in:
@@ -4909,7 +4909,7 @@ def workout_upload_view(request,
|
||||
notes = form.cleaned_data['notes']
|
||||
offline = form.cleaned_data['offline']
|
||||
|
||||
race = None
|
||||
registrationid = 0
|
||||
if optionsform.is_valid():
|
||||
make_plot = optionsform.cleaned_data['make_plot']
|
||||
plottype = optionsform.cleaned_data['plottype']
|
||||
@@ -4923,9 +4923,9 @@ def workout_upload_view(request,
|
||||
landingpage = optionsform.cleaned_data['landingpage']
|
||||
|
||||
try:
|
||||
race = optionsform.cleaned_data['submitrace']
|
||||
registrationid = optionsform.cleaned_data['submitrace']
|
||||
except KeyError:
|
||||
race = None
|
||||
registrationid = 0
|
||||
|
||||
uploadoptions = {
|
||||
'makeprivate':makeprivate,
|
||||
@@ -5113,17 +5113,60 @@ def workout_upload_view(request,
|
||||
else:
|
||||
messages.error(request,message)
|
||||
|
||||
if race and race_can_submit(r,race):
|
||||
if race.sessiontype == 'indoorrace':
|
||||
records = IndoorVirtualRaceResult.objects.filter(
|
||||
race=race,
|
||||
userid=r.id
|
||||
if int(registrationid) < 0:
|
||||
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,
|
||||
)
|
||||
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)
|
||||
elif race.sessiontype == 'indoorrace':
|
||||
race = registrations[0].race
|
||||
result,comments,errors,jobid = add_workout_indoorrace(
|
||||
[w],race,r,
|
||||
)
|
||||
|
||||
if records:
|
||||
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 int(registrationid)>0:
|
||||
races = VirtualRace.objects.filter(
|
||||
registration_closure__gt=timezone.now()
|
||||
)
|
||||
registrations = IndoorVirtualRaceResult.objects.filter(
|
||||
race__in = races,
|
||||
id=registrationid,
|
||||
userid = r.id,
|
||||
)
|
||||
registrations2 = VirtualRaceResult.objects.filter(
|
||||
race__in = races,
|
||||
id=registrationid,
|
||||
userid=r.id,
|
||||
)
|
||||
|
||||
if int(registrationid) in [r.id for r in registrations]:
|
||||
# indoor race
|
||||
registrations = registrations.filter(id=registrationid)
|
||||
if registrations:
|
||||
race = registrations[0].race
|
||||
result,comments,errors,jobid = add_workout_indoorrace(
|
||||
[w],race,r,recordid=records[0].id
|
||||
[w],race,r,recordid=registrations[0].id
|
||||
)
|
||||
|
||||
if result:
|
||||
@@ -5135,15 +5178,15 @@ def workout_upload_view(request,
|
||||
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:
|
||||
if int(registrationid) in [r.id for r in registrations2]:
|
||||
# race
|
||||
registrations = registrations2.filter(id=registrationid)
|
||||
if registrations:
|
||||
race = registrations[0].race
|
||||
result,comments,errors,jobid = add_workout_race(
|
||||
[w], race,r,recordid=records[0].id
|
||||
[w], race,r,recordid=registrations[0].id
|
||||
)
|
||||
if result:
|
||||
messages.info(
|
||||
@@ -5156,6 +5199,7 @@ def workout_upload_view(request,
|
||||
messages.error(request,er)
|
||||
|
||||
|
||||
|
||||
if landingpage != 'workout_upload_view':
|
||||
url = reverse(landingpage,
|
||||
kwargs = {
|
||||
|
||||
Reference in New Issue
Block a user