improved race uploading
This commit is contained in:
@@ -25,6 +25,8 @@ from rowers.models import (
|
|||||||
|
|
||||||
from rowers.courses import get_time_course
|
from rowers.courses import get_time_course
|
||||||
|
|
||||||
|
import rowers.mytypes as mytypes
|
||||||
|
|
||||||
import metrics
|
import metrics
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import dataprep
|
import dataprep
|
||||||
@@ -35,7 +37,6 @@ from rowers.tasks import handle_check_race_course
|
|||||||
|
|
||||||
def get_indoorraces(workout):
|
def get_indoorraces(workout):
|
||||||
races1 = VirtualRace.objects.filter(
|
races1 = VirtualRace.objects.filter(
|
||||||
registration_closure__gt=timezone.now(),
|
|
||||||
sessiontype='indoorrace',
|
sessiontype='indoorrace',
|
||||||
startdate__lte=workout.date,
|
startdate__lte=workout.date,
|
||||||
enddate__gte=workout.date,
|
enddate__gte=workout.date,
|
||||||
@@ -48,7 +49,6 @@ def get_indoorraces(workout):
|
|||||||
|
|
||||||
|
|
||||||
races2 = VirtualRace.objects.filter(
|
races2 = VirtualRace.objects.filter(
|
||||||
registration_closure__gt=timezone.now(),
|
|
||||||
sessiontype='indoorrace',
|
sessiontype='indoorrace',
|
||||||
startdate__lte=workout.date,
|
startdate__lte=workout.date,
|
||||||
enddate__gte=workout.date,
|
enddate__gte=workout.date,
|
||||||
@@ -1009,6 +1009,9 @@ def add_workout_indoorrace(ws,race,r,recordid=0):
|
|||||||
record.duration = ws[0].duration
|
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:
|
if ws[0].weightcategory != record.weightcategory:
|
||||||
errors.append('Your workout weight category did not match the weight category you registered')
|
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")
|
errors.append("Couldn't find this entry")
|
||||||
return result,comments,errors,0
|
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:
|
if ws[0].boattype != record.boattype:
|
||||||
errors.append('Your workout boat type did not match the boat type you registered')
|
errors.append('Your workout boat type did not match the boat type you registered')
|
||||||
return 0,comments,errors,0
|
return 0,comments,errors,0
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ $('#id_workouttype').change();
|
|||||||
<h1>Racing</h1>
|
<h1>Racing</h1>
|
||||||
{% for race in indoorraces %}
|
{% for race in indoorraces %}
|
||||||
<p>
|
<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>
|
</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -158,6 +158,8 @@ urlpatterns = [
|
|||||||
url(r'^virtualevent/(?P<id>\d+)/withdraw$',views.virtualevent_withdraw_view),
|
url(r'^virtualevent/(?P<id>\d+)/withdraw$',views.virtualevent_withdraw_view),
|
||||||
url(r'^virtualevent/(?P<id>\d+)/submit$',
|
url(r'^virtualevent/(?P<id>\d+)/submit$',
|
||||||
views.virtualevent_submit_result_view),
|
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+)/',
|
url(r'^virtualevent/(?P<raceid>\d+)/disqualify/(?P<recordid>\d+)/',
|
||||||
views.virtualevent_disqualify_view),
|
views.virtualevent_disqualify_view),
|
||||||
url(r'^list-workouts/$',views.workouts_view),
|
url(r'^list-workouts/$',views.workouts_view),
|
||||||
|
|||||||
@@ -10023,7 +10023,10 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
|
|
||||||
row = get_workout(id)
|
row = get_workout(id)
|
||||||
|
|
||||||
|
if row.workouttype in mytypes.otetypes:
|
||||||
indoorraces = get_indoorraces(row)
|
indoorraces = get_indoorraces(row)
|
||||||
|
else:
|
||||||
|
indoorraces = []
|
||||||
|
|
||||||
if (checkworkoutuser(request.user,row)==False):
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
raise PermissionDenied("Access denied")
|
raise PermissionDenied("Access denied")
|
||||||
@@ -17403,7 +17406,7 @@ def indoorvirtualevent_edit_view(request,id=0):
|
|||||||
|
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def virtualevent_submit_result_view(request,id=0):
|
def virtualevent_submit_result_view(request,id=0,workoutid=0):
|
||||||
|
|
||||||
r = getrower(request.user)
|
r = getrower(request.user)
|
||||||
|
|
||||||
@@ -17456,6 +17459,7 @@ def virtualevent_submit_result_view(request,id=0):
|
|||||||
|
|
||||||
ws = Workout.objects.filter(
|
ws = Workout.objects.filter(
|
||||||
user=r,
|
user=r,
|
||||||
|
workouttype__in=mytypes.rowtypes,
|
||||||
startdatetime__gte=startdatetime,
|
startdatetime__gte=startdatetime,
|
||||||
startdatetime__lte=enddatetime,
|
startdatetime__lte=enddatetime,
|
||||||
).order_by("date","startdatetime","id")
|
).order_by("date","startdatetime","id")
|
||||||
@@ -17531,6 +17535,8 @@ def virtualevent_submit_result_view(request,id=0):
|
|||||||
if result:
|
if result:
|
||||||
otherrecords = resultobj.objects.filter(
|
otherrecords = resultobj.objects.filter(
|
||||||
race = race).exclude(userid = r.id)
|
race = race).exclude(userid = r.id)
|
||||||
|
if not jobid:
|
||||||
|
messages.info(request,"Result submitted successfully.")
|
||||||
|
|
||||||
for otherrecord in otherrecords:
|
for otherrecord in otherrecords:
|
||||||
otheruser = Rower.objects.get(id=otherrecord.userid)
|
otheruser = Rower.objects.get(id=otherrecord.userid)
|
||||||
@@ -17556,8 +17562,12 @@ def virtualevent_submit_result_view(request,id=0):
|
|||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
if workoutid:
|
||||||
|
workoutdata['initial'] = workoutid
|
||||||
w_form = WorkoutRaceSelectForm(workoutdata,entries)
|
w_form = WorkoutRaceSelectForm(workoutdata,entries)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
breadcrumbs = [
|
breadcrumbs = [
|
||||||
{
|
{
|
||||||
'url':reverse(virtualevents_view),
|
'url':reverse(virtualevents_view),
|
||||||
|
|||||||
Reference in New Issue
Block a user