first version result table virtualrace
This commit is contained in:
@@ -1329,6 +1329,7 @@ class VirtualRaceResult(models.Model):
|
|||||||
user = models.ForeignKey(Rower)
|
user = models.ForeignKey(Rower)
|
||||||
username = models.CharField(max_length=150)
|
username = models.CharField(max_length=150)
|
||||||
workout = models.ForeignKey(Workout)
|
workout = models.ForeignKey(Workout)
|
||||||
|
weightcategory = models.CharField(default="hwt",max_length=10)
|
||||||
race = models.ForeignKey(VirtualRace)
|
race = models.ForeignKey(VirtualRace)
|
||||||
duration = models.TimeField(default=3600)
|
duration = models.TimeField(default=3600)
|
||||||
boattype = models.CharField(choices=boattypes,max_length=40,
|
boattype = models.CharField(choices=boattypes,max_length=40,
|
||||||
|
|||||||
@@ -493,6 +493,23 @@ def race_rower_status(r,race):
|
|||||||
|
|
||||||
return is_complete,has_registered
|
return is_complete,has_registered
|
||||||
|
|
||||||
|
def race_can_edit(r,race):
|
||||||
|
if r.user != race.manager:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
start_time = race.start_time
|
||||||
|
start_date = race.startdate
|
||||||
|
startdatetime = datetime.combine(start_date,start_time)
|
||||||
|
startdatetime = pytz.timezone(race.timezone).localize(
|
||||||
|
startdatetime
|
||||||
|
)
|
||||||
|
if timezone.now()<startdatetime:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def race_can_submit(r,race):
|
def race_can_submit(r,race):
|
||||||
if r not in race.rower.all():
|
if r not in race.rower.all():
|
||||||
|
|||||||
@@ -10,12 +10,6 @@
|
|||||||
|
|
||||||
<h1>{{ race.name }}</h1>
|
<h1>{{ race.name }}</h1>
|
||||||
|
|
||||||
{% if request.user == race.manager %}
|
|
||||||
<div class="grid_2 alpha">
|
|
||||||
<p>
|
|
||||||
<a href="/rowers/virtualevent/{{ race.id }}/edit" class="button gray small">Edit</a>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -78,11 +72,14 @@
|
|||||||
<a href="/rowers/virtualevent/{{ race.id }}/submit" class="button gray small grid_2">Submit Result</a>
|
<a href="/rowers/virtualevent/{{ race.id }}/submit" class="button gray small grid_2">Submit Result</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if button == 'resubmitbutton' %}
|
{% if button == 'resubmitbutton' %}
|
||||||
<a href="/rowers/virtualevent/{{ race.id }}/resubmit" class="button gray small grid_2">Submit New Result</a>
|
<a href="/rowers/virtualevent/{{ race.id }}/submit" class="button gray small grid_2">Submit New Result</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if button == 'withdrawbutton' %}
|
{% if button == 'withdrawbutton' %}
|
||||||
<a href="/rowers/virtualevent/{{ race.id }}/withdraw" class="button gray small grid_2">Withdraw</a>
|
<a href="/rowers/virtualevent/{{ race.id }}/withdraw" class="button gray small grid_2">Withdraw</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if button == 'editbutton' %}
|
||||||
|
<a href="/rowers/virtualevent/{{ race.id }}/edit" class="button gray small grid_2">Edit Race</a>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -90,7 +87,41 @@
|
|||||||
<div id="results">
|
<div id="results">
|
||||||
<h2>Results</h2>
|
<h2>Results</h2>
|
||||||
<p>
|
<p>
|
||||||
|
{% if results %}
|
||||||
|
<table class="listtable shortpadded" width="100%">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th> </th>
|
||||||
|
<th> </th>
|
||||||
|
<th> </th>
|
||||||
|
<th>Boat</th>
|
||||||
|
<th>Raw Time</th>
|
||||||
|
<th>In Class</th>
|
||||||
|
<th>Corrected Time</th>
|
||||||
|
<th>Corrected Place</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for result in results %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ forloop.counter }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="/rowers/workout/{{ result.workout.id }}">
|
||||||
|
{{ result.username }}</a></td>
|
||||||
|
<td>{{ result.age }}</td>
|
||||||
|
<td>{{ result.sex }}</td>
|
||||||
|
<td>{{ result.weightcategory }}</td>
|
||||||
|
<td>{{ result.boattype }}</td>
|
||||||
|
<td>{{ result.duration |durationprint:"%H:%M:%S.%f" }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
No results yet
|
No results yet
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="rules">
|
<div id="rules">
|
||||||
|
|||||||
@@ -13403,6 +13403,12 @@ def virtualevent_view(request,id=0):
|
|||||||
if race_can_withdraw(r,race):
|
if race_can_withdraw(r,race):
|
||||||
buttons += ['withdrawbutton']
|
buttons += ['withdrawbutton']
|
||||||
|
|
||||||
|
if race_can_edit(r,race):
|
||||||
|
buttons += ['editbutton']
|
||||||
|
|
||||||
|
results = VirtualRaceResult.objects.filter(
|
||||||
|
race=race
|
||||||
|
).order_by("duration")
|
||||||
|
|
||||||
return render(request,'virtualevent.html',
|
return render(request,'virtualevent.html',
|
||||||
{
|
{
|
||||||
@@ -13410,6 +13416,7 @@ def virtualevent_view(request,id=0):
|
|||||||
'coursediv':div,
|
'coursediv':div,
|
||||||
'race':race,
|
'race':race,
|
||||||
'rower':r,
|
'rower':r,
|
||||||
|
'results':results,
|
||||||
'buttons':buttons,
|
'buttons':buttons,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -13550,6 +13557,20 @@ def virtualevent_edit_view(request,id=0):
|
|||||||
except VirtualRace.DoesNotExist:
|
except VirtualRace.DoesNotExist:
|
||||||
raise Http404("Virtual Race does not exist")
|
raise Http404("Virtual Race does not exist")
|
||||||
|
|
||||||
|
start_time = race.start_time
|
||||||
|
start_date = race.startdate
|
||||||
|
startdatetime = datetime.datetime.combine(start_date,start_time)
|
||||||
|
startdatetime = pytz.timezone(race.timezone).localize(
|
||||||
|
startdatetime
|
||||||
|
)
|
||||||
|
|
||||||
|
if timezone.now() > startdatetime:
|
||||||
|
messages.error(request,"You cannot edit a race after the start of the race window")
|
||||||
|
url = reverse(virtualevent_view,
|
||||||
|
kwargs={
|
||||||
|
'id':race.id,
|
||||||
|
})
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
racecreateform = VirtualRaceForm(request.POST,instance=race)
|
racecreateform = VirtualRaceForm(request.POST,instance=race)
|
||||||
if racecreateform.is_valid():
|
if racecreateform.is_valid():
|
||||||
@@ -13664,8 +13685,14 @@ def virtualevent_submit_result_view(request,id=0):
|
|||||||
for er in errors:
|
for er in errors:
|
||||||
messages.error(request,er)
|
messages.error(request,er)
|
||||||
|
|
||||||
|
|
||||||
# redirect to race page
|
# redirect to race page
|
||||||
|
url = reverse(virtualevent_view,
|
||||||
|
kwargs = {
|
||||||
|
'id':race.id
|
||||||
|
})
|
||||||
|
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
w_form = WorkoutRaceSelectForm(workoutdata=workoutdata)
|
w_form = WorkoutRaceSelectForm(workoutdata=workoutdata)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user