upload workout to fastest challenge now works
This commit is contained in:
@@ -5017,7 +5017,7 @@ def workout_upload_view(request,
|
||||
response = {}
|
||||
if request.method == 'POST':
|
||||
form = DocumentsForm(request.POST,request.FILES)
|
||||
optionsform = UploadOptionsForm(request.POST,request=request,raceid=raceid)
|
||||
optionsform = UploadOptionsForm(request.POST,request=request)
|
||||
|
||||
if form.is_valid():
|
||||
# f = request.FILES['file']
|
||||
@@ -5058,6 +5058,7 @@ def workout_upload_view(request,
|
||||
upload_to_tp = optionsform.cleaned_data['upload_to_TrainingPeaks']
|
||||
makeprivate = optionsform.cleaned_data['makeprivate']
|
||||
landingpage = optionsform.cleaned_data['landingpage']
|
||||
raceid = optionsform.cleaned_data['raceid']
|
||||
|
||||
try:
|
||||
registrationid = optionsform.cleaned_data['submitrace']
|
||||
@@ -5285,11 +5286,27 @@ def workout_upload_view(request,
|
||||
messages.info(request,c)
|
||||
for er in errors:
|
||||
messages.error(request,er)
|
||||
elif race.sessiontype in ['fastest_time','fastest_distance']:
|
||||
result,comments,errors,jobid = add_workout_fastestrace(
|
||||
[w], race,r,doregister=True,
|
||||
)
|
||||
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()
|
||||
)
|
||||
if raceid != 0:
|
||||
races = VirtualRace.objects.filter(
|
||||
registration_closure__gt=timezone.now(),
|
||||
id=raceid,
|
||||
)
|
||||
|
||||
registrations = IndoorVirtualRaceResult.objects.filter(
|
||||
race__in = races,
|
||||
id=registrationid,
|
||||
@@ -5306,8 +5323,13 @@ def workout_upload_view(request,
|
||||
registrations = registrations.filter(id=registrationid)
|
||||
if registrations:
|
||||
race = registrations[0].race
|
||||
result,comments,errors,jobid = add_workout_indoorrace(
|
||||
[w],race,r,recordid=registrations[0].id
|
||||
if race.sessiontype == 'indoorrace':
|
||||
result,comments,errors,jobid = add_workout_indoorrace(
|
||||
[w],race,r,recordid=registrations[0].id
|
||||
)
|
||||
elif race.sessiontype in ['fastest_time','fastest_distance']:
|
||||
result,comments, errors,jobid = add_workout_fastestrace(
|
||||
[w],race,r,recordid=registrations[0].id
|
||||
)
|
||||
|
||||
if result:
|
||||
@@ -5326,9 +5348,14 @@ def workout_upload_view(request,
|
||||
registrations = registrations2.filter(id=registrationid)
|
||||
if registrations:
|
||||
race = registrations[0].race
|
||||
result,comments,errors,jobid = add_workout_race(
|
||||
[w], race,r,recordid=registrations[0].id
|
||||
)
|
||||
if race.sessiontype == 'race':
|
||||
result,comments,errors,jobid = add_workout_race(
|
||||
[w], race,r,recordid=registrations[0].id
|
||||
)
|
||||
elif race.sessiontype in ['fastest_time','fastest_distance']:
|
||||
result, comments, errors, jobid = add_workout_fastestrace(
|
||||
[w],race,r,recordid=registrations[0].id
|
||||
)
|
||||
if result:
|
||||
messages.info(
|
||||
request,
|
||||
|
||||
Reference in New Issue
Block a user