Private
Public Access
1
0

race registration records now with id

This commit is contained in:
Sander Roosendaal
2018-04-21 08:51:38 +02:00
parent 1db23056d0
commit 98ab345151
5 changed files with 56 additions and 26 deletions

View File

@@ -920,6 +920,7 @@ class PlannedSession(models.Model):
('test','Mandatory Test'),
('cycletarget','Cycle Target'),
('coursetest','OTW test over a course'),
('race','Virtual Race'),
)
sessionmodechoices = (
@@ -1037,14 +1038,14 @@ class PlannedSession(models.Model):
self.sessionmode = 'distance'
self.sessionunit = 'm'
self.criterium = 'exact'
if self.sessiontype == 'coursetest':
if self.sessiontype == 'coursetest' or self.sessiontype == 'race':
self.sessionmode = 'distance'
self.sessionunit = 'm'
self.criterium = 'none'
if self.course == None:
self.course = GeoCourse.objects.all()[0]
self.sessionvalue = course_length(self.course)
elif self.sessiontype != 'coursetest':
elif self.sessiontype != 'coursetest' and self.sessiontype != 'race':
self.course = None
if self.enddate < self.startdate:
@@ -1326,11 +1327,11 @@ def auto_delete_strokedata_on_delete(sender, instance, **kwargs):
# Virtual Race results (for keeping results when workouts are deleted)
class VirtualRaceResult(models.Model):
user = models.ForeignKey(Rower)
teamname = models.CharField(max_length=20,verbose_name = 'Team Name',
userid = models.IntegerField(default=0)
teamname = models.CharField(max_length=80,verbose_name = 'Team Name',
blank=True,null=True)
username = models.CharField(max_length=150)
workout = models.ForeignKey(Workout,blank=True,null=True)
workoutid = models.IntegerField(null=True)
weightcategory = models.CharField(default="hwt",max_length=10,
choices=weightcategories,
verbose_name='Weight Category')

View File

@@ -48,7 +48,7 @@ def add_workouts_plannedsession(ws,ps,r):
ids = [w.id for w in wold] + [w.id for w in ws]
ids = list(set(ids))
if len(ids)>1 and ps.sessiontype in ['test','coursetest']:
if len(ids)>1 and ps.sessiontype in ['test','coursetest','race']:
errors.append('For tests, you can only attach one workout')
return result,comments,errors
@@ -271,7 +271,7 @@ def is_session_complete_ws(ws,ps):
if not completiondate:
completiondate = ws.reverse()[0].date
return ratio,'partial',completiondate
elif ps.sessiontype == 'coursetest':
elif ps.sessiontype in ['coursetest','race']:
if ps.course:
(
coursetime,
@@ -615,8 +615,8 @@ def add_rower_race(r,race):
def remove_rower_race(r,race):
race.rower.remove(r)
records = VirtualRaceResult.objects.filter(user=r,
workout__isnull=True,
records = VirtualRaceResult.objects.filter(userid=r.id,
workoutid__isnull=True,
race=race)
for r in records:
@@ -659,7 +659,7 @@ def add_workout_race(ws,race,r):
ids = [w.id for w in ws]
ids = list(set(ids))
if len(ids)>1 and race.sessiontype in ['test','coursetest']:
if len(ids)>1 and race.sessiontype in ['test','coursetest','race']:
errors.append('For tests, you can only attach one workout')
return result,comments,errors
@@ -693,7 +693,7 @@ def add_workout_race(ws,race,r):
duration = totaltime_sec_to_string(coursetime)
records = VirtualRaceResult.objects.filter(
user=r,
userid=r.id,
race=race
)
@@ -708,18 +708,19 @@ def add_workout_race(ws,race,r):
return result,comments, errors
record.coursecompleted=coursecompleted
record.workout=ws[0]
record.workoutid=ws[0].id
record.duration = duration
record.save()
add_workouts_plannedsession(ws,race,r)
return result,comments,errors
def delete_race_result(workout,race):
results = VirtualRaceResult.objects.filter(workout=workout,race=race)
results = VirtualRaceResult.objects.filter(workoutid=workout.id,race=race)
for r in results:
r.delete()
r.workoutid = None
r.save()

View File

@@ -87,13 +87,29 @@
<tr>
<td>
{% if completeness|lookup:ps.id == 'not done' %}
{% if ps.sessiontype != 'race' %}
<a class="white dot" href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ rower.id }}/session/{{ ps.id }}">&nbsp;</a>
{% else %}
<a class="white dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
{% endif %}
{% elif completeness|lookup:ps.id == 'completed' %}
{% if ps.sessiontype != 'race' %}
<a class="green dot" href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ rower.id }}/session/{{ ps.id }}">&nbsp;</a>
{% else %}
<a class="green dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
{% endif %}
{% elif completeness|lookup:ps.id == 'partial' %}
{% if ps.sessiontype != 'race' %}
<a class="orange dot" href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ rower.id }}/session/{{ ps.id }}">&nbsp;</a>
{% else %}
<a class="orange dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
{% endif %}
{% else %}
{% if ps.sessiontype != 'race' %}
<a class="red dot" href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ rower.id }}/session/{{ ps.id }}">&nbsp;</a>
{% else %}
<a class="red dot" href="/rowers/virtualevent/{{ ps.id }}/submit">&nbsp;</a>
{% endif %}
{% endif %}
</td>
<td> {{ ps.startdate|date:"Y-m-d" }} </td>

View File

@@ -48,7 +48,7 @@
<th>Contact Phone</th><td>{{ race.contact_phone }}</td>
</tr>
<tr>
<th>Comment</th><td>{{ race.comment }}</td>
<th>Comment</th><td>{{ race.comment|linebreaks }}</td>
</tr>
</tbody>
</table>
@@ -57,11 +57,12 @@
<div id="registerbuttons">
{% if request.user.is_anonymous %}
<p>
Registered users of rowsandall.com can participate in this event.
Registered users of rowsandall.com can participate in this event. Participation is free, unless specified differently in the race comment above.
</p>
{% else %}
<p>
See race rules below.
See race rules below. Participation to this race is free,
unless specified differently in the race comment above.
</p>
<p>
{% for button in buttons %}
@@ -109,7 +110,7 @@
<tr>
<td>{{ forloop.counter }}</td>
<td>
<a href="/rowers/workout/{{ result.workout.id }}">
<a href="/rowers/workout/{{ result.workoutid }}">
{{ result.username }}</a></td>
<td>{{ result.teamname }}</th>
<td>{{ result.age }}</td>
@@ -156,8 +157,8 @@
<td>{{ record.username }}
<td>{{ record.teamname }}</td>
<td>{{ record.boattype }}</td>
<td>{{ record.weightcategory }}</td>
<td>{{ record.age }}</td>
<td>{{ record.weightcategory }}</td>
</tr>
{% endfor %}
</tbody>
@@ -166,6 +167,11 @@
</div>
<div id="rules">
<h2>Rules</h2>
<p>
Virtual races are intended as an informal way to add a
competitive element to training and as a quick way to set
up and manage small regattas.
</p>
<p>
As a rowsandall.com user, you can
register to take part in this event.
@@ -180,7 +186,7 @@
After the start of the race window and before the submission deadline,
you can submit results by linking the race to one of your uploaded
workouts. The workout start time must be within the race window
and your trajectory must pass through the blue polygons on the course
and your course must pass through the blue polygons on the course
map (in the right order), for your result to be valid.
</p>
<p>
@@ -199,6 +205,13 @@
corrected times, please be sure your gender and birth date are set
correctly in your user settings.
</p>
<p>
Virtual races are intended as an informal way to add a
competitive element to training. Virtual races are not
refereed or staffed to provide for participants safety.
Individual participants are entirely responsible for their
safety while participating in a virtual race.
</p>
</div>
</div>
<div class="grid_4 omega">

View File

@@ -13407,16 +13407,15 @@ def virtualevent_view(request,id=0):
results = VirtualRaceResult.objects.filter(
race=race,
workout__isnull=False,
workoutid__isnull=False,
).order_by("duration")
# to-do - add DNS
dns = []
if timezone.now() > race.evaluation_closure:
print "aap"
dns = VirtualRaceResult.objects.filter(
race=race,
workout__isnull=True,
workoutid__isnull=True,
)
print dns[0].username,"noot"
@@ -13494,7 +13493,7 @@ def virtualevent_register_view(request,id=0):
age = calculate_age(r.birthdate)
record = VirtualRaceResult(
user=r,
userid=r.id,
teamname=teamname,
race=race,
username = u'{f} {l}'.format(
@@ -13539,7 +13538,7 @@ def virtualevent_register_view(request,id=0):
{
'form':form,
'race':race,
'rower':r,
'rowerid':r.id,
})