added manual and upload links to race page
This commit is contained in:
@@ -2690,7 +2690,7 @@ class WorkoutForm(ModelForm):
|
||||
startdate__lte=workout.date,
|
||||
enddate__gte=workout.date,
|
||||
).order_by("preferreddate","startdate","enddate").exclude(
|
||||
sessiontype='race')
|
||||
sessiontype__in=['race','indoorrace'])
|
||||
|
||||
if not sps:
|
||||
del self.fields['plannedsession']
|
||||
|
||||
@@ -20,7 +20,7 @@ from rowers.models import (
|
||||
Rower, Workout,Team,
|
||||
GeoCourse, TrainingMicroCycle,TrainingMesoCycle,TrainingMacroCycle,
|
||||
TrainingPlan,PlannedSession,VirtualRaceResult,CourseTestResult,
|
||||
get_course_timezone, IndoorVirtualRaceResult
|
||||
get_course_timezone, IndoorVirtualRaceResult,VirtualRace
|
||||
)
|
||||
|
||||
from rowers.courses import get_time_course
|
||||
@@ -33,6 +33,41 @@ import iso8601
|
||||
from iso8601 import ParseError
|
||||
from rowers.tasks import handle_check_race_course
|
||||
|
||||
def get_indoorraces(workout):
|
||||
races1 = VirtualRace.objects.filter(
|
||||
registration_closure__gt=timezone.now(),
|
||||
sessiontype='indoorrace',
|
||||
startdate__lte=workout.date,
|
||||
enddate__gte=workout.date,
|
||||
sessionmode='distance',
|
||||
sessionvalue=workout.distance)
|
||||
|
||||
|
||||
if workout.duration.second != 0 and workout.duration.microsecond != 0:
|
||||
duration = 60*workout.duration.hour+workout.duration.minute
|
||||
|
||||
|
||||
races2 = VirtualRace.objects.filter(
|
||||
registration_closure__gt=timezone.now(),
|
||||
sessiontype='indoorrace',
|
||||
startdate__lte=workout.date,
|
||||
enddate__gte=workout.date,
|
||||
sessionmode='time',
|
||||
sessionvalue=duration)
|
||||
|
||||
races = races1 | races2
|
||||
else:
|
||||
races = races1
|
||||
|
||||
registrations = IndoorVirtualRaceResult.objects.filter(
|
||||
race__in = races,
|
||||
userid=workout.user.id)
|
||||
|
||||
races = [r.race for r in registrations]
|
||||
|
||||
|
||||
return races
|
||||
|
||||
def get_todays_micro(plan,thedate=date.today()):
|
||||
thismicro = None
|
||||
|
||||
|
||||
@@ -155,7 +155,37 @@ data-text="@rowsandall #rowingdata Participate in Indoor Rowing virtual race '{{
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if button == 'submitbutton' %}
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/submit">Submit Result</a>
|
||||
<table width=100% class="shortpadded">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/submit">Submit Workout</a>
|
||||
</td>
|
||||
<td>
|
||||
Submit a workout that is already on the site as your race result
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/rowers/upload">Upload your race result</a>
|
||||
</td>
|
||||
<td>
|
||||
Upload a new workout to the site and submit it as a result. You
|
||||
need a workout data file.
|
||||
</td>
|
||||
</tr>
|
||||
{% if race.sessiontype == 'indoorrace' %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/rowers/addmanual">Enter your race result manually</a>
|
||||
</td>
|
||||
<td>
|
||||
If you don't have a data file, enter the results
|
||||
manually. If you have a photo of the monitor with the
|
||||
result, it is recommended to add this to the workout.
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% endif %}
|
||||
{% if button == 'resubmitbutton' %}
|
||||
<p>
|
||||
|
||||
@@ -118,6 +118,16 @@ $('#id_workouttype').change();
|
||||
</pre>
|
||||
</p>
|
||||
</li>
|
||||
{% if indoorraces %}
|
||||
<li>
|
||||
<h1>Racing</h1>
|
||||
{% for race in indoorraces %}
|
||||
<p>
|
||||
<a href="/rowers/virtualevent/{{ race.id }}/submit">Submit this to Indoor Race {{ race.name }}</a>
|
||||
</p>
|
||||
{% endfor %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if mapdiv %}
|
||||
<li class="grid_2">
|
||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||
|
||||
@@ -3460,6 +3460,12 @@ def addmanual_view(request):
|
||||
add_workouts_plannedsession([w],ps,w.user)
|
||||
|
||||
messages.info(request,'New workout created')
|
||||
|
||||
url = reverse(
|
||||
workout_edit_view,
|
||||
kwargs={'id':id}
|
||||
)
|
||||
return HttpResponseRedirect(url)
|
||||
else:
|
||||
return render(request,'manualadd.html',
|
||||
{'form':form,
|
||||
@@ -9979,6 +9985,8 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
row = get_workout(id)
|
||||
|
||||
indoorraces = get_indoorraces(row)
|
||||
|
||||
if (checkworkoutuser(request.user,row)==False):
|
||||
raise PermissionDenied("Access denied")
|
||||
|
||||
@@ -10171,6 +10179,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
'graphs':g,
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'rower':r,
|
||||
'indoorraces':indoorraces,
|
||||
'active':'nav-workouts',
|
||||
'mapscript':mapscript,
|
||||
'mapdiv':mapdiv,
|
||||
|
||||
Reference in New Issue
Block a user