race registration records now with id
This commit is contained in:
@@ -920,6 +920,7 @@ class PlannedSession(models.Model):
|
|||||||
('test','Mandatory Test'),
|
('test','Mandatory Test'),
|
||||||
('cycletarget','Cycle Target'),
|
('cycletarget','Cycle Target'),
|
||||||
('coursetest','OTW test over a course'),
|
('coursetest','OTW test over a course'),
|
||||||
|
('race','Virtual Race'),
|
||||||
)
|
)
|
||||||
|
|
||||||
sessionmodechoices = (
|
sessionmodechoices = (
|
||||||
@@ -1037,14 +1038,14 @@ class PlannedSession(models.Model):
|
|||||||
self.sessionmode = 'distance'
|
self.sessionmode = 'distance'
|
||||||
self.sessionunit = 'm'
|
self.sessionunit = 'm'
|
||||||
self.criterium = 'exact'
|
self.criterium = 'exact'
|
||||||
if self.sessiontype == 'coursetest':
|
if self.sessiontype == 'coursetest' or self.sessiontype == 'race':
|
||||||
self.sessionmode = 'distance'
|
self.sessionmode = 'distance'
|
||||||
self.sessionunit = 'm'
|
self.sessionunit = 'm'
|
||||||
self.criterium = 'none'
|
self.criterium = 'none'
|
||||||
if self.course == None:
|
if self.course == None:
|
||||||
self.course = GeoCourse.objects.all()[0]
|
self.course = GeoCourse.objects.all()[0]
|
||||||
self.sessionvalue = course_length(self.course)
|
self.sessionvalue = course_length(self.course)
|
||||||
elif self.sessiontype != 'coursetest':
|
elif self.sessiontype != 'coursetest' and self.sessiontype != 'race':
|
||||||
self.course = None
|
self.course = None
|
||||||
|
|
||||||
if self.enddate < self.startdate:
|
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)
|
# Virtual Race results (for keeping results when workouts are deleted)
|
||||||
class VirtualRaceResult(models.Model):
|
class VirtualRaceResult(models.Model):
|
||||||
user = models.ForeignKey(Rower)
|
userid = models.IntegerField(default=0)
|
||||||
teamname = models.CharField(max_length=20,verbose_name = 'Team Name',
|
teamname = models.CharField(max_length=80,verbose_name = 'Team Name',
|
||||||
blank=True,null=True)
|
blank=True,null=True)
|
||||||
username = models.CharField(max_length=150)
|
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,
|
weightcategory = models.CharField(default="hwt",max_length=10,
|
||||||
choices=weightcategories,
|
choices=weightcategories,
|
||||||
verbose_name='Weight Category')
|
verbose_name='Weight Category')
|
||||||
|
|||||||
@@ -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 = [w.id for w in wold] + [w.id for w in ws]
|
||||||
ids = list(set(ids))
|
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')
|
errors.append('For tests, you can only attach one workout')
|
||||||
return result,comments,errors
|
return result,comments,errors
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ def is_session_complete_ws(ws,ps):
|
|||||||
if not completiondate:
|
if not completiondate:
|
||||||
completiondate = ws.reverse()[0].date
|
completiondate = ws.reverse()[0].date
|
||||||
return ratio,'partial',completiondate
|
return ratio,'partial',completiondate
|
||||||
elif ps.sessiontype == 'coursetest':
|
elif ps.sessiontype in ['coursetest','race']:
|
||||||
if ps.course:
|
if ps.course:
|
||||||
(
|
(
|
||||||
coursetime,
|
coursetime,
|
||||||
@@ -615,8 +615,8 @@ def add_rower_race(r,race):
|
|||||||
def remove_rower_race(r,race):
|
def remove_rower_race(r,race):
|
||||||
race.rower.remove(r)
|
race.rower.remove(r)
|
||||||
|
|
||||||
records = VirtualRaceResult.objects.filter(user=r,
|
records = VirtualRaceResult.objects.filter(userid=r.id,
|
||||||
workout__isnull=True,
|
workoutid__isnull=True,
|
||||||
race=race)
|
race=race)
|
||||||
|
|
||||||
for r in records:
|
for r in records:
|
||||||
@@ -659,7 +659,7 @@ def add_workout_race(ws,race,r):
|
|||||||
ids = [w.id for w in ws]
|
ids = [w.id for w in ws]
|
||||||
ids = list(set(ids))
|
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')
|
errors.append('For tests, you can only attach one workout')
|
||||||
return result,comments,errors
|
return result,comments,errors
|
||||||
|
|
||||||
@@ -693,7 +693,7 @@ def add_workout_race(ws,race,r):
|
|||||||
duration = totaltime_sec_to_string(coursetime)
|
duration = totaltime_sec_to_string(coursetime)
|
||||||
|
|
||||||
records = VirtualRaceResult.objects.filter(
|
records = VirtualRaceResult.objects.filter(
|
||||||
user=r,
|
userid=r.id,
|
||||||
race=race
|
race=race
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -708,18 +708,19 @@ def add_workout_race(ws,race,r):
|
|||||||
return result,comments, errors
|
return result,comments, errors
|
||||||
|
|
||||||
record.coursecompleted=coursecompleted
|
record.coursecompleted=coursecompleted
|
||||||
record.workout=ws[0]
|
record.workoutid=ws[0].id
|
||||||
record.duration = duration
|
record.duration = duration
|
||||||
record.save()
|
record.save()
|
||||||
|
|
||||||
|
add_workouts_plannedsession(ws,race,r)
|
||||||
|
|
||||||
|
|
||||||
return result,comments,errors
|
return result,comments,errors
|
||||||
|
|
||||||
def delete_race_result(workout,race):
|
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:
|
for r in results:
|
||||||
r.delete()
|
r.workoutid = None
|
||||||
|
r.save()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -87,13 +87,29 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{% if completeness|lookup:ps.id == 'not done' %}
|
{% 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 }}"> </a>
|
<a class="white dot" href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ rower.id }}/session/{{ ps.id }}"> </a>
|
||||||
|
{% else %}
|
||||||
|
<a class="white dot" href="/rowers/virtualevent/{{ ps.id }}/submit"> </a>
|
||||||
|
{% endif %}
|
||||||
{% elif completeness|lookup:ps.id == 'completed' %}
|
{% 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 }}"> </a>
|
<a class="green dot" href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ rower.id }}/session/{{ ps.id }}"> </a>
|
||||||
|
{% else %}
|
||||||
|
<a class="green dot" href="/rowers/virtualevent/{{ ps.id }}/submit"> </a>
|
||||||
|
{% endif %}
|
||||||
{% elif completeness|lookup:ps.id == 'partial' %}
|
{% 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 }}"> </a>
|
<a class="orange dot" href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ rower.id }}/session/{{ ps.id }}"> </a>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
<a class="orange dot" href="/rowers/virtualevent/{{ ps.id }}/submit"> </a>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% if ps.sessiontype != 'race' %}
|
||||||
<a class="red dot" href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ rower.id }}/session/{{ ps.id }}"> </a>
|
<a class="red dot" href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ rower.id }}/session/{{ ps.id }}"> </a>
|
||||||
|
{% else %}
|
||||||
|
<a class="red dot" href="/rowers/virtualevent/{{ ps.id }}/submit"> </a>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td> {{ ps.startdate|date:"Y-m-d" }} </td>
|
<td> {{ ps.startdate|date:"Y-m-d" }} </td>
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
<th>Contact Phone</th><td>{{ race.contact_phone }}</td>
|
<th>Contact Phone</th><td>{{ race.contact_phone }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Comment</th><td>{{ race.comment }}</td>
|
<th>Comment</th><td>{{ race.comment|linebreaks }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -57,11 +57,12 @@
|
|||||||
<div id="registerbuttons">
|
<div id="registerbuttons">
|
||||||
{% if request.user.is_anonymous %}
|
{% if request.user.is_anonymous %}
|
||||||
<p>
|
<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>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<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>
|
||||||
<p>
|
<p>
|
||||||
{% for button in buttons %}
|
{% for button in buttons %}
|
||||||
@@ -109,7 +110,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{ forloop.counter }}</td>
|
<td>{{ forloop.counter }}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="/rowers/workout/{{ result.workout.id }}">
|
<a href="/rowers/workout/{{ result.workoutid }}">
|
||||||
{{ result.username }}</a></td>
|
{{ result.username }}</a></td>
|
||||||
<td>{{ result.teamname }}</th>
|
<td>{{ result.teamname }}</th>
|
||||||
<td>{{ result.age }}</td>
|
<td>{{ result.age }}</td>
|
||||||
@@ -156,8 +157,8 @@
|
|||||||
<td>{{ record.username }}
|
<td>{{ record.username }}
|
||||||
<td>{{ record.teamname }}</td>
|
<td>{{ record.teamname }}</td>
|
||||||
<td>{{ record.boattype }}</td>
|
<td>{{ record.boattype }}</td>
|
||||||
<td>{{ record.weightcategory }}</td>
|
|
||||||
<td>{{ record.age }}</td>
|
<td>{{ record.age }}</td>
|
||||||
|
<td>{{ record.weightcategory }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -166,6 +167,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="rules">
|
<div id="rules">
|
||||||
<h2>Rules</h2>
|
<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>
|
<p>
|
||||||
As a rowsandall.com user, you can
|
As a rowsandall.com user, you can
|
||||||
register to take part in this event.
|
register to take part in this event.
|
||||||
@@ -180,7 +186,7 @@
|
|||||||
After the start of the race window and before the submission deadline,
|
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
|
you can submit results by linking the race to one of your uploaded
|
||||||
workouts. The workout start time must be within the race window
|
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.
|
map (in the right order), for your result to be valid.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -199,6 +205,13 @@
|
|||||||
corrected times, please be sure your gender and birth date are set
|
corrected times, please be sure your gender and birth date are set
|
||||||
correctly in your user settings.
|
correctly in your user settings.
|
||||||
</p>
|
</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>
|
</div>
|
||||||
<div class="grid_4 omega">
|
<div class="grid_4 omega">
|
||||||
|
|||||||
@@ -13407,16 +13407,15 @@ def virtualevent_view(request,id=0):
|
|||||||
|
|
||||||
results = VirtualRaceResult.objects.filter(
|
results = VirtualRaceResult.objects.filter(
|
||||||
race=race,
|
race=race,
|
||||||
workout__isnull=False,
|
workoutid__isnull=False,
|
||||||
).order_by("duration")
|
).order_by("duration")
|
||||||
|
|
||||||
# to-do - add DNS
|
# to-do - add DNS
|
||||||
dns = []
|
dns = []
|
||||||
if timezone.now() > race.evaluation_closure:
|
if timezone.now() > race.evaluation_closure:
|
||||||
print "aap"
|
|
||||||
dns = VirtualRaceResult.objects.filter(
|
dns = VirtualRaceResult.objects.filter(
|
||||||
race=race,
|
race=race,
|
||||||
workout__isnull=True,
|
workoutid__isnull=True,
|
||||||
)
|
)
|
||||||
print dns[0].username,"noot"
|
print dns[0].username,"noot"
|
||||||
|
|
||||||
@@ -13494,7 +13493,7 @@ def virtualevent_register_view(request,id=0):
|
|||||||
age = calculate_age(r.birthdate)
|
age = calculate_age(r.birthdate)
|
||||||
|
|
||||||
record = VirtualRaceResult(
|
record = VirtualRaceResult(
|
||||||
user=r,
|
userid=r.id,
|
||||||
teamname=teamname,
|
teamname=teamname,
|
||||||
race=race,
|
race=race,
|
||||||
username = u'{f} {l}'.format(
|
username = u'{f} {l}'.format(
|
||||||
@@ -13539,7 +13538,7 @@ def virtualevent_register_view(request,id=0):
|
|||||||
{
|
{
|
||||||
'form':form,
|
'form':form,
|
||||||
'race':race,
|
'race':race,
|
||||||
'rower':r,
|
'rowerid':r.id,
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user