Merge branch 'feature/courses' into develop
This commit is contained in:
@@ -26,6 +26,18 @@
|
|||||||
<i class="fas fa-pause fa-fw"></i> Intervals
|
<i class="fas fa-pause fa-fw"></i> Intervals
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if workout|water %}
|
||||||
|
<li id="workout-courses">
|
||||||
|
<a href="/rowers/workout/{{ workout.id|encode }}/courses/">
|
||||||
|
<i class="fas fa-route fa-fw"></i> Measured Courses
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
<li>
|
||||||
|
<a href="/rowers/workout/{{ workout.id|encode }}/editintervals/">
|
||||||
|
<i class="fas fa-pause fa-fw"></i> Intervals
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li id="workout-comments">
|
<li id="workout-comments">
|
||||||
|
|||||||
106
rowers/templates/workout_courses.html
Normal file
106
rowers/templates/workout_courses.html
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
{% extends "newbase.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
{% load leaflet_tags %}
|
||||||
|
|
||||||
|
{% block meta %}
|
||||||
|
{% leaflet_js %}
|
||||||
|
{% leaflet_css %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}{{ workout.name }} {% endblock %}
|
||||||
|
{% block og_title %}{{ workout.name }} {% endblock %}
|
||||||
|
{% block description %}{{ workout.name }}
|
||||||
|
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
|
||||||
|
{% block og_description %}{{ workout.name }}
|
||||||
|
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
|
||||||
|
<h1>{{ workout.name }}</h1>
|
||||||
|
<ul class="main-content">
|
||||||
|
{% if records %}
|
||||||
|
<li class="grid_4">
|
||||||
|
<h2>Course Results</h2>
|
||||||
|
<table class="listtable shortpadded">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Course</th>
|
||||||
|
<th>Time</th>
|
||||||
|
<th>Distance</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for record in records %}
|
||||||
|
<tr>
|
||||||
|
<td><a href="/rowers/courses/{{ record.course.id }}">{{ record.course.name }}</a></td>
|
||||||
|
<td>{{ record.duration |durationprint:"%H:%M:%S.%f" }}</td>
|
||||||
|
<td>{{ record.distance }} m</td>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if courses %}
|
||||||
|
<li class="grid_4">
|
||||||
|
<h2>Add a course</h2>
|
||||||
|
<p>
|
||||||
|
This functionality allows you to record a time on a set course that you've rowed during the workout.
|
||||||
|
The summary will be updated to show time on course, and you can compare this with other
|
||||||
|
attempts.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{% if rower.share_course_results %}
|
||||||
|
You are currently sharing your course results with all Rowsandall users.
|
||||||
|
Click <a href="/rowers/me/edit/?courseshare=false">here</a> to hide your course results.
|
||||||
|
{% else %}
|
||||||
|
You are currently hiding your course results (except for your participation in online challenges).
|
||||||
|
Click <a href="/rowers/me/edit/?courseshare=true">here</a> to hide your course results.
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
<form ecntype="multipart/form-data" method="post">
|
||||||
|
<table>
|
||||||
|
{{ courseselectform.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
<input class="button" type="submit" value="Select Course">
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
<li class="grid_2">
|
||||||
|
<h2>Workout Summary</h2>
|
||||||
|
<table width=100%>
|
||||||
|
<tr>
|
||||||
|
<th>Rower:</th><td>{{ first_name }} {{ last_name }}</td>
|
||||||
|
</tr><tr>
|
||||||
|
<tr>
|
||||||
|
<th>Name:</th><td>{{ workout.name }}</td>
|
||||||
|
</tr><tr>
|
||||||
|
<tr>
|
||||||
|
<th>Date:</th><td>{{ workout.date }}</td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Time:</th><td>{{ workout.starttime }}</td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Distance:</th><td>{{ workout.distance }}m</td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Duration:</th><td>{{ workout.duration |durationprint:"%H:%M:%S.%f" }}</td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Type:</th><td>{{ workout.workouttype }}</td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Weight Category:</th><td>{{ workout.weightcategory }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_workout.html' %}
|
||||||
|
{% endblock %}
|
||||||
@@ -650,6 +650,8 @@ urlpatterns = [
|
|||||||
re_path(r'^register/thankyou/$', TemplateView.as_view(template_name='registerthankyou.html'), name='registerthankyou'),
|
re_path(r'^register/thankyou/$', TemplateView.as_view(template_name='registerthankyou.html'), name='registerthankyou'),
|
||||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/workflow/$',views.workout_workflow_view,
|
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/workflow/$',views.workout_workflow_view,
|
||||||
name='workout_workflow_view'),
|
name='workout_workflow_view'),
|
||||||
|
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/courses/$',views.workout_course_view,
|
||||||
|
name='workout_course_view'),
|
||||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/flexchart/(?P<xparam>[\w\ ]+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)/(?P<plottype>\w+)/$',views.workout_flexchart3_view,name='workout_flexchart3_view'),
|
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/flexchart/(?P<xparam>[\w\ ]+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)/(?P<plottype>\w+)/$',views.workout_flexchart3_view,name='workout_flexchart3_view'),
|
||||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)/(?P<plottype>\w+.*)/$',views.workout_flexchart3_view,name='workout_flexchart3_view'),
|
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)/(?P<plottype>\w+.*)/$',views.workout_flexchart3_view,name='workout_flexchart3_view'),
|
||||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)/$',views.workout_flexchart3_view,name='workout_flexchart3_view'),
|
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)/$',views.workout_flexchart3_view,name='workout_flexchart3_view'),
|
||||||
|
|||||||
@@ -765,6 +765,7 @@ verbose_job_status = {
|
|||||||
'long_test_task2': 'Long Test Task 2',
|
'long_test_task2': 'Long Test Task 2',
|
||||||
'update_empower': 'Correct Empower Inflated Power Bug',
|
'update_empower': 'Correct Empower Inflated Power Bug',
|
||||||
'submit_race': 'Checking Race Course Result',
|
'submit_race': 'Checking Race Course Result',
|
||||||
|
'check_race_course': 'Checking Course Result',
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_job_status(jobid): # pragma: no cover
|
def get_job_status(jobid): # pragma: no cover
|
||||||
|
|||||||
@@ -6058,6 +6058,104 @@ def workout_fusion_view(request,id1=0,id2=1):
|
|||||||
'workout2':w2,
|
'workout2':w2,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# See attached courses
|
||||||
|
@login_required()
|
||||||
|
@permission_required('workout.change_workout',fn=get_workout_by_opaqueid, raise_exception=True)
|
||||||
|
def workout_course_view(request, id):
|
||||||
|
row = get_workout_by_opaqueid(request,id)
|
||||||
|
r = getrower(request.user)
|
||||||
|
breadcrumbs = [
|
||||||
|
{
|
||||||
|
'url':'/rowers/list-workouts/',
|
||||||
|
'name':'Workouts'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':get_workout_default_page(request,encoder.encode_hex(row.id)),
|
||||||
|
'name': row.name
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse('workout_course_view',kwargs={'id':id}),
|
||||||
|
'name': 'Measured Courses'
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
courses = []
|
||||||
|
courseselectform = CourseSelectForm()
|
||||||
|
has_latlon,lat_mean,lon_mean = dataprep.workout_has_latlon(row.id)
|
||||||
|
if has_latlon:
|
||||||
|
courses = getnearestcourses([lat_mean,lon_mean],GeoCourse.objects.all(),whatisnear=25,
|
||||||
|
strict=True)
|
||||||
|
courseselectform = CourseSelectForm(choices=courses)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
courseselectform = CourseSelectForm(request.POST,choices=courses)
|
||||||
|
if courseselectform.is_valid():
|
||||||
|
course = courseselectform.cleaned_data['course']
|
||||||
|
# get or create a record
|
||||||
|
records = VirtualRaceResult.objects.filter(
|
||||||
|
userid=r.id,
|
||||||
|
course=course,
|
||||||
|
workoutid=row.id
|
||||||
|
)
|
||||||
|
if records:
|
||||||
|
record = records[0]
|
||||||
|
else:
|
||||||
|
# create record
|
||||||
|
record = VirtualRaceResult(
|
||||||
|
userid = r.id,
|
||||||
|
username = r.user.first_name+' '+r.user.last_name,
|
||||||
|
workoutid = row.id,
|
||||||
|
weightcategory = r.weightcategory,
|
||||||
|
adaptiveclass = r.adaptiveclass,
|
||||||
|
course = course,
|
||||||
|
distance = course.distance,
|
||||||
|
boatclass = row.workouttype,
|
||||||
|
boattype = row.boattype,
|
||||||
|
sex = r.sex,
|
||||||
|
age = calculate_age(r.birthdate),
|
||||||
|
)
|
||||||
|
record.save()
|
||||||
|
|
||||||
|
job = myqueue(
|
||||||
|
queuehigh,
|
||||||
|
handle_check_race_course,
|
||||||
|
row.csvfilename,
|
||||||
|
row.id,
|
||||||
|
course.id,
|
||||||
|
record.id,
|
||||||
|
r.user.email,
|
||||||
|
r.user.first_name,
|
||||||
|
summary=True,
|
||||||
|
successemail=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
request.session['async_tasks'] += [(job.id,'check_race_course')]
|
||||||
|
except KeyError:
|
||||||
|
request.session['async_tasks'] = [(job.id,'check_race_course')]
|
||||||
|
|
||||||
|
messages.info(request,'We are checking your time on the course in the background. You will receive an email when the check is complete. You can check the status <a href="/rowers/jobs-status/" target="_blank">here</a>')
|
||||||
|
|
||||||
|
# get results
|
||||||
|
records = VirtualRaceResult.objects.filter(
|
||||||
|
course__isnull=False,
|
||||||
|
workoutid=row.id,
|
||||||
|
coursecompleted=True).order_by("duration","-distance")
|
||||||
|
|
||||||
|
return render(request, 'workout_courses.html',
|
||||||
|
{'workout':row,
|
||||||
|
'rower':r,
|
||||||
|
'breadcrumbs':breadcrumbs,
|
||||||
|
'active':'nav-workouts',
|
||||||
|
'teams':get_my_teams(request.user),
|
||||||
|
'courses':courses,
|
||||||
|
'courseselectform':courseselectform,
|
||||||
|
'records':records,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
# Edit the splits/summary
|
# Edit the splits/summary
|
||||||
@login_required()
|
@login_required()
|
||||||
@@ -6229,7 +6327,13 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|||||||
summary=True,
|
summary=True,
|
||||||
successemail=True,
|
successemail=True,
|
||||||
)
|
)
|
||||||
messages.info(request,'We are checking your time on the course in the background')
|
|
||||||
|
try:
|
||||||
|
request.session['async_tasks'] += [(job.id,'check_race_course')]
|
||||||
|
except KeyError:
|
||||||
|
request.session['async_tasks'] = [(job.id,'check_race_course')]
|
||||||
|
|
||||||
|
messages.info(request,'We are checking your time on the course in the background. You will receive an email when the check is complete. You can check the status <a href="/rowers/jobs-status/" target="_blank">here</a>')
|
||||||
|
|
||||||
vals = None
|
vals = None
|
||||||
# feeling lucky / ruptures
|
# feeling lucky / ruptures
|
||||||
|
|||||||
Reference in New Issue
Block a user