more refs to old page removed
This commit is contained in:
@@ -10,9 +10,11 @@
|
||||
</li>
|
||||
<li id="compare">
|
||||
{% if team %}
|
||||
<a href="/rowers/team-compare-select/team/{{ team.id }}/"><i class="fas fa-balance-scale fa-fw"></i> Compare</a>
|
||||
<a href="/rowers/user-analysis-select/compare/team/{{ team.id }}/">
|
||||
<i class="fas fa-balance-scale fa-fw"></i> Compare</a>
|
||||
{% else %}
|
||||
<a href="/rowers/team-compare-select/team/0/"><i class="fas fa-balance-scale fa-fw"></i> Compare</a>
|
||||
<a href="/rowers/user-analysis-select/compare/team/0/">
|
||||
<i class="fas fa-balance-scale fa-fw"></i> Compare</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
</li>
|
||||
<li id="compare">
|
||||
{% if team %}
|
||||
<a href="/rowers/user-analysis-select/team/{{ team.id }}/">
|
||||
<a href="/rowers/user-analysis-select/compare/team/{{ team.id }}/">
|
||||
<i class="fas fa-balance-scale fa-fw"></i> Compare</a>
|
||||
{% else %}
|
||||
<a href="/rowers/user-analysis-select/team/0/">
|
||||
<a href="/rowers/user-analysis-select/compare/team/0/">
|
||||
<i class="fas fa-balance-scale fa-fw"></i> Compare</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
{% extends "newbase.html" %}
|
||||
{% load static %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block title %}Workouts{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<script>
|
||||
function toggle(source) {
|
||||
checkboxes = document.querySelectorAll("input[name='workouts']");
|
||||
for(var i=0, n=checkboxes.length;i<n;i++) {
|
||||
checkboxes[i].checked = source.checked;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
// Get the form fields and hidden div
|
||||
var modality = $("#id_modality");
|
||||
var hidden = $("#id_waterboattype");
|
||||
|
||||
|
||||
// Hide the fields.
|
||||
// Use JS to do this in case the user doesn't have JS
|
||||
// enabled.
|
||||
|
||||
hidden.hide();
|
||||
|
||||
if (modality.val() == 'water') {
|
||||
hidden.show();
|
||||
}
|
||||
|
||||
// Setup an event listener for when the state of the
|
||||
// checkbox changes.
|
||||
modality.change(function() {
|
||||
// Check to see if the checkbox is checked.
|
||||
// If it is, show the fields and populate the input.
|
||||
// If not, hide the fields.
|
||||
var Value = modality.val();
|
||||
if (Value=='water') {
|
||||
// Show the hidden fields.
|
||||
hidden.show();
|
||||
} else {
|
||||
// Make sure that the hidden fields are indeed
|
||||
// hidden.
|
||||
hidden.hide();
|
||||
|
||||
// You may also want to clear the value of the
|
||||
// hidden fields here. Just in case somebody
|
||||
// shows the fields, enters data to them and then
|
||||
// unticks the checkbox.
|
||||
//
|
||||
// This would do the job:
|
||||
//
|
||||
// $("#hidden_field").val("");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<h1>{{ team.name }} Compare Workouts</h1>
|
||||
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_4">
|
||||
<p>Select two or more workouts on the left, set your plot settings,
|
||||
and press submit</p>
|
||||
<p>
|
||||
You can use the date and search forms to search through all
|
||||
workouts from this team.
|
||||
</p>
|
||||
<p>
|
||||
TIP: Agree with your team members to put tags (e.g. '8x500m')
|
||||
in the notes section of
|
||||
your workouts. That makes it easy to search.
|
||||
</p>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<form enctype="multipart/form-data"
|
||||
action=""
|
||||
method="post">
|
||||
<table>
|
||||
{{ dateform.as_table }}
|
||||
</table>
|
||||
<table>
|
||||
{{ modalityform.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
<p>
|
||||
<input name='modalityform' class="button green" type="submit" value="Filter">
|
||||
</p>
|
||||
</form>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<form id="searchform"
|
||||
action=""
|
||||
method="get" accept-charset="utf-8">
|
||||
{{ searchform }}
|
||||
<input type="submit" value="GO"></input>
|
||||
</form>
|
||||
</li>
|
||||
<li class="grid_2 maxheight">
|
||||
{% if workouts %}
|
||||
<form enctype="multipart/form-data"
|
||||
action="/rowers/multi-compare/"
|
||||
method="post">
|
||||
|
||||
<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
|
||||
|
||||
<table width="100%" class="listtable">
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
|
||||
{% else %}
|
||||
<p> No workouts found </p>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<p>
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
{{ chartform.as_table }}
|
||||
</table>
|
||||
</p>
|
||||
<p>
|
||||
<input name="chartform" type="submit" value="Compare">
|
||||
</p>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_workouts.html' %}
|
||||
{% endblock %}
|
||||
@@ -6,7 +6,7 @@
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/team-compare-select/team/{{ teamid }}/">Multi Compare</a>
|
||||
<a class="button gray small" href="/rowers/user-analysis-select/compare/{{ teamid }}/">Multi Compare</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
|
||||
@@ -16,6 +16,7 @@ from django.db import transaction
|
||||
import json
|
||||
|
||||
from rowers.views.workoutviews import plannedsession_compare_view
|
||||
from rowers.views.analysisviews import analysis_new
|
||||
from rowers.views.otherviews import download_fit
|
||||
from rowers.opaque import encoder
|
||||
from django.utils.crypto import get_random_string
|
||||
@@ -443,7 +444,11 @@ class SessionLinkTest(TestCase):
|
||||
|
||||
url = reverse(plannedsession_compare_view,kwargs={'id':ps.id,'userid':self.u.id})
|
||||
response = self.c.get(url,follow=True)
|
||||
expected_url = reverse('multi_compare_view',kwargs={'userid':self.u.id,'id':encoder.encode_hex(w.id)})
|
||||
expected_url = reverse('analysis_new',
|
||||
kwargs={'function':'compare',
|
||||
'id':encoder.encode_hex(w.id),
|
||||
'session':ps.id,
|
||||
})
|
||||
self.assertRedirects(response,expected_url=expected_url,
|
||||
status_code=302,target_status_code=200)
|
||||
|
||||
@@ -473,7 +478,7 @@ class SessionLinkTest(TestCase):
|
||||
session.save()
|
||||
|
||||
request.user = self.u
|
||||
response = multi_compare_view(request,id=str(w.id))
|
||||
response = analysis_new(request,id=encoder.encode_hex(w.id))
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
# and adding a get
|
||||
@@ -491,7 +496,7 @@ class SessionLinkTest(TestCase):
|
||||
session.save()
|
||||
|
||||
request.user = self.u
|
||||
response = multi_compare_view(request,id=str(w.id))
|
||||
response = analysis_new(request,id=encoder.encode_hex(w.id))
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -316,9 +316,12 @@ urlpatterns = [
|
||||
re_path(r'^workouts-join/user/(?P<userid>\d+)$',views.workouts_join_view,name='workouts_join_view'),
|
||||
re_path(r'^workouts-join-select/$',views.workouts_join_select,name='workouts_join_select'),
|
||||
re_path(r'^workouts-join-select/user/(?P<userid>\d+)/$',views.workouts_join_select,name='workouts_join_select'),
|
||||
re_path(r'^user-analysis-select/(?P<function>\w.*)/team/(?P<teamid>\d+)/workout/(?P<id>\b[0-9A-Fa-f]+\b)/$',views.analysis_new,name='analysis_new'),
|
||||
re_path(r'^user-analysis-select/(?P<function>\w.*)/session/(?P<session>\d+)/workout/(?P<id>\b[0-9A-Fa-f]+\b)/$',views.analysis_new,name='analysis_new'),
|
||||
re_path(r'^user-analysis-select/(?P<function>\w.*)/workout/(?P<id>\b[0-9A-Fa-f]+\b)/$',views.analysis_new,name='analysis_new'),
|
||||
re_path(r'^user-analysis-select/(?P<function>\w.*)/user/(?P<userid>\d+)/$',views.analysis_new,name='analysis_new'),
|
||||
re_path(r'^user-analysis-select/(?P<function>\w.*)/team/(?P<teamid>\d+)/$',views.analysis_new,name='analysis_new'),
|
||||
re_path(r'^user-analysis-select/team/(?P<teamid>\d+)/workout/(?P<id>\b[0-9A-Fa-f]+\b)/$',views.analysis_new,name='analysis_new'),
|
||||
re_path(r'^user-analysis-select/user/(?P<userid>\d+)/$',views.analysis_new,name='analysis_new'),
|
||||
re_path(r'^user-analysis-select/team/(?P<teamid>\d+)/$',views.analysis_new,name='analysis_new'),
|
||||
re_path(r'^user-analysis-select/(?P<function>\w.*)/$',views.analysis_new,name='analysis_new'),
|
||||
|
||||
@@ -8,6 +8,7 @@ from rowers.views.statements import *
|
||||
import collections
|
||||
import simplejson
|
||||
from jinja2 import Template,Environment,FileSystemLoader
|
||||
from rowers.rower_rules import can_view_session
|
||||
|
||||
def floatformat(x,prec=2): # pragma: no cover
|
||||
return '{x}'.format(x=round(x,prec))
|
||||
@@ -35,7 +36,7 @@ defaultoptions = {
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
@permission_required('rower.is_coach',fn=get_user_by_userid,raise_exception=True)
|
||||
def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
||||
def analysis_new(request,userid=0,function='boxplot',teamid=0,id='',session=0):
|
||||
r = getrequestrower(request, userid=userid)
|
||||
user = r.user
|
||||
userid = user.id
|
||||
@@ -53,6 +54,13 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
||||
except Team.DoesNotExist:
|
||||
theteam = None
|
||||
|
||||
try:
|
||||
thesession = PlannedSession.objects.get(id=session)
|
||||
if not can_view_session(user,thesession):
|
||||
raise PermissionDenied("you cannot view this session")
|
||||
except PlannedSession.DoesNotExist:
|
||||
thesession = None
|
||||
|
||||
|
||||
if 'options' in request.session:
|
||||
options = request.session['options']
|
||||
@@ -211,6 +219,8 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
||||
startdatetime__lte=enddate,
|
||||
workouttype__in=modalities,
|
||||
)
|
||||
elif thesession is not None:
|
||||
workouts = get_workouts_session(r,thesession)
|
||||
else:
|
||||
workouts = Workout.objects.filter(user=r,
|
||||
startdatetime__gte=startdate,
|
||||
|
||||
@@ -2047,9 +2047,14 @@ def plannedsession_compare_view(request,id=0,userid=0):
|
||||
request.session['plottype'] = plottype
|
||||
request.session['ps'] = ps.id
|
||||
|
||||
teams = ps.team.all()
|
||||
|
||||
if ids:
|
||||
url = reverse('multi_compare_view',
|
||||
kwargs={'userid':userid,'id':encoder.encode_hex(ids[0])})
|
||||
url = reverse('analysis_new',
|
||||
kwargs={
|
||||
'session':ps.id,
|
||||
'id':encoder.encode_hex(ids[0]),
|
||||
'function':'compare'})
|
||||
else:
|
||||
url = reverse('plannedsession_view',kwargs={'id':ps.id})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user