Private
Public Access
1
0

first result working

This commit is contained in:
Sander Roosendaal
2020-05-27 14:56:09 +02:00
parent 8bfbb2bdf8
commit 2ba9133a1d
9 changed files with 112 additions and 45 deletions

View File

@@ -2252,7 +2252,7 @@ class VirtualRace(PlannedSession):
validators=[validate_email],blank=True)
coursestandards = models.ForeignKey(StandardCollection,null=True,on_delete=models.SET_NULL,
verbose_name='Standard Times')
verbose_name='Standard Times',blank=True)
def __str__(self):
@@ -2954,6 +2954,7 @@ class VirtualRaceResult(models.Model):
startsecond = models.FloatField(default=0)
endsecond = models.FloatField(default=0)
referencespeed = models.FloatField(default=5.0)
entrycategory = models.ForeignKey(CourseStandard,null=True,on_delete=models.SET_NULL,
verbose_name='Group')

View File

@@ -1514,6 +1514,7 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0):
return 0,comments,errors,0
if ws[0].workouttype != record.boatclass:
print(ws[0].workouttype,record.boatclass)
errors.append('Your workout boat class is different than on your race registration')
return 0,comments,errors,0
@@ -1551,7 +1552,8 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0):
comments.append('Workouts submitted to virtual events have to be public. We have changed the workout to a public workout.')
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,
referencespeed=record.referencespeed)

View File

@@ -17,6 +17,10 @@ def save_scoring(name,user,filename,id=0,notes=""):
collection.name = name
collection.notes = notes
collection.save()
standards = CourseStandard.objects.filter(standardcollection=collection)
for standard in standards:
print(standard,collection)
standard.delete()
except StandardCollection.DoesNotExist:
return 0
@@ -56,6 +60,20 @@ def save_scoring(name,user,filename,id=0,notes=""):
try:
boatclass = row['BoatClass']
if boatclass.lower() in ['standard','olympic','normal']:
boatclass = 'water'
elif boatclass.lower() in ['erg','c2','concept','static']:
boatclass = 'rower'
elif boatclass.lower() in ['dynamic']:
boatclass = 'dynamic'
elif boatclass.lower() in ['slides','slide','slider','sliders']:
boatclass = 'slides'
elif boatclass.lower() in ['c','c-boat']:
boatclass = 'c-boat'
elif boatclass.lower() in ['coastal','coast']:
boatclass = 'coastal'
elif boatclass.lower() in ['church','churchboat','finnish','finland']:
boatclass = 'churchboat'
except KeyError:
boatclass = 'water'

View File

@@ -353,6 +353,16 @@ def handle_check_race_course(self,
else:
splitsecond = 0
if 'referencespeed' in kwargs:
referencespeed = kwargs['referencespeed']
else:
referencespeed = 5.0
if 'coursedistance' in kwargs:
coursedistance = kwargs['coursedistance']
else:
coursedistance = 0
mode = 'race'
if 'mode' in kwargs:
mode = kwargs['mode']
@@ -479,22 +489,28 @@ def handle_check_race_course(self,
else:
coursecompleted = False
points = 0
if coursecompleted:
query = 'UPDATE rowers_virtualraceresult SET coursecompleted = 1, duration = "{duration}", distance = {distance}, workoutid = {workoutid}, startsecond = {startsecond}, endsecond = {endsecond} WHERE id={recordid}'.format(
if coursedistance == 0:
coursedistance = coursemeters
velo = coursedistance/coursetimeseconds
points = int(100*(2.-referencespeed/velo))
query = 'UPDATE rowers_virtualraceresult SET coursecompleted = 1, duration = "{duration}", distance = {distance}, workoutid = {workoutid}, startsecond = {startsecond}, endsecond = {endsecond}, points={points} WHERE id={recordid}'.format(
recordid=recordid,
duration=totaltime_sec_to_string(coursetimeseconds),
distance=int(coursemeters),
points=points,
workoutid=workoutid,
startsecond=startsecond,
endsecond=endsecond,
)
if mode == 'coursetest':
query = 'UPDATE rowers_coursetestresult SET coursecompleted = 1, duration = "{duration}", distance = {distance}, workoutid = {workoutid}, startsecond = {startsecond}, endsecond = {endsecond} WHERE id={recordid}'.format(
query = 'UPDATE rowers_coursetestresult SET coursecompleted = 1, duration = "{duration}", distance = {distance}, workoutid = {workoutid}, startsecond = {startsecond}, endsecond = {endsecond}, points={points} WHERE id={recordid}'.format(
recordid=recordid,
duration=totaltime_sec_to_string(coursetimeseconds),
distance=int(coursemeters),
points=points,
workoutid=workoutid,
startsecond=startsecond,
endsecond=endsecond,

View File

@@ -187,7 +187,7 @@
$.ajax({
data: data,
type: $(this).attr('method'),
url: '/rowers/standards/upload/',
url: window.location.pathname,
contentType: false,
processData: false,
error: function(result) {

View File

@@ -268,7 +268,9 @@
<th>&nbsp;</th>
<th>Name</th>
<th>Team Name</th>
<th>&nbsp;</th>
{% if race.coursestandards %}
<th>Group</th>
{% else %}
<th>&nbsp;</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
@@ -276,8 +278,12 @@
{% if race.sessiontype == 'race' %}
<th>Boat</th>
{% endif %}
{% endif %}
<th>Time</th>
<th>Distance</th>
{% if race.coursestandards %}
<th>Points</th>
{% endif %}
<th>Details</th>
<th>&nbsp;</th>
</tr>
@@ -290,6 +296,9 @@
<a href="/rowers/workout/{{ result.workoutid|encode }}/view/entry/{{ result.id }}/">
{{ result.username }}</a></td>
<td>{{ result.teamname }}</td>
{% if race.coursestandards %}
<td>{{ result.entrycategory }}</td>
{% else %}
<td>{{ result.age }}</td>
<td>{{ result.sex }}</td>
<td>{{ result.weightcategory }}</td>
@@ -304,11 +313,17 @@
{% if race.sessiontype == 'race' %}
<td>{{ result.boattype }}</td>
{% endif %}
{% endif %}
<td>{{ result.duration |durationprint:"%H:%M:%S.%f" }}</td>
<td>{{ result.distance }} m</td>
{% if race.coursestandards %}
<td>{{ result.points }}</td>
{% endif %}
<td>
<a href="/rowers/workout/{{ result.workoutid|encode }}/view/entry/{{ result.id }}/">
Details</a></td>
Details</a>
</td>
<td>
{% if race.manager == request.user and not race|is_final %}
<a href="/rowers/virtualevent/{{ race.id }}/disqualify/{{ result.id }}/">
@@ -394,22 +409,29 @@
<tr>
<th>Name</th>
<th>Team Name</th>
{% if race.sessiontype == 'race' %}
<th>Class</th>
<th>Boat</th>
{% if race.coursestandards %}
<th>Group</th>
<th>Age</th>
{% else %}
<th>Class</th>
{% if race.sessiontype == 'race' %}
<th>Boat</th>
{% endif %}
<th>Class</th>
<th>Age</th>
<th>Gender</th>
<th>Weight Category</th>
<th>Adaptive</th>
{% endif %}
</tr>
<tbody>
{% for record in records %}
<tr>
<td>{{ record.username }}
<td>{{ record.teamname }}</td>
{% if race.coursestandards %}
<td>{{ record.entrycategory }}</td>
<td>{{ record.age }}</td>
{% else %}
<td>{{ record.boatclass }}</td>
{% if race.sessiontype == 'race' %}
<td>{{ record.boattype }}</td>
@@ -424,6 +446,7 @@
{{ record.adaptiveclass }}
{% endif %}
</td>
{% endif %}
{% if record.userid == rower.id and 'withdrawbutton' in buttons %}
<td>
<a href="/rowers/virtualevent/{{ race.id }}/withdraw/{{ record.id }}" >Withdraw</a>

View File

@@ -525,6 +525,7 @@ def course_upload_view(request):
@login_required()
def standards_upload_view(request,id=0):
is_ajax = False
print(id,'aap')
if request.is_ajax():
is_ajax = True
r = getrower(request.user)
@@ -573,6 +574,8 @@ def standards_upload_view(request,id=0):
messages.error(request,'Form is not valid')
return render(request,'standard_form.html',
{'form':form,
'active':'nav-racing',
'id':id,
})
else:
@@ -587,6 +590,7 @@ def standards_upload_view(request,id=0):
return render(request,'standard_form.html',
{'form':form,
'active':'nav-racing',
'id':id,
})
return {'result':0}
@@ -1127,8 +1131,6 @@ def virtualevent_view(request,id=0):
else:
form = None
breadcrumbs = [
{
'url':reverse('virtualevents_view'),
@@ -1687,6 +1689,7 @@ def virtualevent_register_view(request,id=0):
sex=sex,
age=age,
entrycategory=coursestandard,
referencespeed=referencespeed,
)
record.save()