Private
Public Access
1
0

improved race uploading

This commit is contained in:
Sander Roosendaal
2018-12-09 11:17:20 +01:00
parent d3866f2dec
commit 1e8ba12d12
4 changed files with 25 additions and 5 deletions

View File

@@ -25,6 +25,8 @@ from rowers.models import (
from rowers.courses import get_time_course
import rowers.mytypes as mytypes
import metrics
import numpy as np
import dataprep
@@ -35,7 +37,6 @@ from rowers.tasks import handle_check_race_course
def get_indoorraces(workout):
races1 = VirtualRace.objects.filter(
registration_closure__gt=timezone.now(),
sessiontype='indoorrace',
startdate__lte=workout.date,
enddate__gte=workout.date,
@@ -48,7 +49,6 @@ def get_indoorraces(workout):
races2 = VirtualRace.objects.filter(
registration_closure__gt=timezone.now(),
sessiontype='indoorrace',
startdate__lte=workout.date,
enddate__gte=workout.date,
@@ -1009,6 +1009,9 @@ def add_workout_indoorrace(ws,race,r,recordid=0):
record.duration = ws[0].duration
if ws[0].workouttype not in mytypes.otetypes:
errors.append('You must submit a indoor rowing workout')
return 0,comments, errors, 0
if ws[0].weightcategory != record.weightcategory:
errors.append('Your workout weight category did not match the weight category you registered')
@@ -1102,6 +1105,11 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0):
errors.append("Couldn't find this entry")
return result,comments,errors,0
if ws[0].workouttype not in mytypes.otwtypes:
errors.append('You have to submit a rowing on water workout')
return 0,comments,errors,0
if ws[0].boattype != record.boattype:
errors.append('Your workout boat type did not match the boat type you registered')
return 0,comments,errors,0

View File

@@ -123,7 +123,7 @@ $('#id_workouttype').change();
<h1>Racing</h1>
{% for race in indoorraces %}
<p>
<a href="/rowers/virtualevent/{{ race.id }}/submit">Submit this to Indoor Race {{ race.name }}</a>
<a href="/rowers/virtualevent/{{ race.id }}/submit/{{ workout.id }}">Submit this to Indoor Race {{ race.name }}</a>
</p>
{% endfor %}
</li>

View File

@@ -158,6 +158,8 @@ urlpatterns = [
url(r'^virtualevent/(?P<id>\d+)/withdraw$',views.virtualevent_withdraw_view),
url(r'^virtualevent/(?P<id>\d+)/submit$',
views.virtualevent_submit_result_view),
url(r'^virtualevent/(?P<id>\d+)/submit/(?P<workoutid>\d+)$',
views.virtualevent_submit_result_view),
url(r'^virtualevent/(?P<raceid>\d+)/disqualify/(?P<recordid>\d+)/',
views.virtualevent_disqualify_view),
url(r'^list-workouts/$',views.workouts_view),

View File

@@ -10023,7 +10023,10 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
row = get_workout(id)
indoorraces = get_indoorraces(row)
if row.workouttype in mytypes.otetypes:
indoorraces = get_indoorraces(row)
else:
indoorraces = []
if (checkworkoutuser(request.user,row)==False):
raise PermissionDenied("Access denied")
@@ -17403,7 +17406,7 @@ def indoorvirtualevent_edit_view(request,id=0):
@login_required()
def virtualevent_submit_result_view(request,id=0):
def virtualevent_submit_result_view(request,id=0,workoutid=0):
r = getrower(request.user)
@@ -17456,6 +17459,7 @@ def virtualevent_submit_result_view(request,id=0):
ws = Workout.objects.filter(
user=r,
workouttype__in=mytypes.rowtypes,
startdatetime__gte=startdatetime,
startdatetime__lte=enddatetime,
).order_by("date","startdatetime","id")
@@ -17531,6 +17535,8 @@ def virtualevent_submit_result_view(request,id=0):
if result:
otherrecords = resultobj.objects.filter(
race = race).exclude(userid = r.id)
if not jobid:
messages.info(request,"Result submitted successfully.")
for otherrecord in otherrecords:
otheruser = Rower.objects.get(id=otherrecord.userid)
@@ -17556,8 +17562,12 @@ def virtualevent_submit_result_view(request,id=0):
return HttpResponseRedirect(url)
else:
if workoutid:
workoutdata['initial'] = workoutid
w_form = WorkoutRaceSelectForm(workoutdata,entries)
breadcrumbs = [
{
'url':reverse(virtualevents_view),