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) validators=[validate_email],blank=True)
coursestandards = models.ForeignKey(StandardCollection,null=True,on_delete=models.SET_NULL, coursestandards = models.ForeignKey(StandardCollection,null=True,on_delete=models.SET_NULL,
verbose_name='Standard Times') verbose_name='Standard Times',blank=True)
def __str__(self): def __str__(self):
@@ -2954,6 +2954,7 @@ class VirtualRaceResult(models.Model):
startsecond = models.FloatField(default=0) startsecond = models.FloatField(default=0)
endsecond = 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, entrycategory = models.ForeignKey(CourseStandard,null=True,on_delete=models.SET_NULL,
verbose_name='Group') 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 return 0,comments,errors,0
if ws[0].workouttype != record.boatclass: 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') errors.append('Your workout boat class is different than on your race registration')
return 0,comments,errors,0 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.') 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, 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.name = name
collection.notes = notes collection.notes = notes
collection.save() collection.save()
standards = CourseStandard.objects.filter(standardcollection=collection)
for standard in standards:
print(standard,collection)
standard.delete()
except StandardCollection.DoesNotExist: except StandardCollection.DoesNotExist:
return 0 return 0
@@ -56,6 +60,20 @@ def save_scoring(name,user,filename,id=0,notes=""):
try: try:
boatclass = row['BoatClass'] 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: except KeyError:
boatclass = 'water' boatclass = 'water'

View File

@@ -353,6 +353,16 @@ def handle_check_race_course(self,
else: else:
splitsecond = 0 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' mode = 'race'
if 'mode' in kwargs: if 'mode' in kwargs:
mode = kwargs['mode'] mode = kwargs['mode']
@@ -479,22 +489,28 @@ def handle_check_race_course(self,
else: else:
coursecompleted = False coursecompleted = False
points = 0
if coursecompleted: 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, recordid=recordid,
duration=totaltime_sec_to_string(coursetimeseconds), duration=totaltime_sec_to_string(coursetimeseconds),
distance=int(coursemeters), distance=int(coursemeters),
points=points,
workoutid=workoutid, workoutid=workoutid,
startsecond=startsecond, startsecond=startsecond,
endsecond=endsecond, endsecond=endsecond,
) )
if mode == 'coursetest': 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, recordid=recordid,
duration=totaltime_sec_to_string(coursetimeseconds), duration=totaltime_sec_to_string(coursetimeseconds),
distance=int(coursemeters), distance=int(coursemeters),
points=points,
workoutid=workoutid, workoutid=workoutid,
startsecond=startsecond, startsecond=startsecond,
endsecond=endsecond, endsecond=endsecond,

View File

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

View File

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

View File

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

View File

@@ -112,6 +112,10 @@ th {
.paddedtable td { padding: 1px 20px } .paddedtable td { padding: 1px 20px }
.shortpadded th { padding: 3px 3px }
.paddedtable th { padding: 1px 20px }
.cortable { .cortable {
border-collapse: collapse; border-collapse: collapse;
} }

File diff suppressed because one or more lines are too long