menu_analytics and boxplot-select
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
<h1>Analysis</h1>
|
<h1>Analysis</h1>
|
||||||
<ul class="cd-accordion-menu animated">
|
<ul class="cd-accordion-menu animated">
|
||||||
<li class="has-children" id="fitness">
|
<li class="has-children" id="fitness">
|
||||||
@@ -65,3 +67,27 @@
|
|||||||
<i class="fas fa-flask fa-fw"></i> Laboratory</a>
|
<i class="fas fa-flask fa-fw"></i> Laboratory</a>
|
||||||
</li>
|
</li>
|
||||||
</ul><!-- cd-accordion-menu -->
|
</ul><!-- cd-accordion-menu -->
|
||||||
|
|
||||||
|
{% if user.is_authenticated and user|is_manager %}
|
||||||
|
<p> </p>
|
||||||
|
|
||||||
|
<ul class="cd-accordion-menu animated">
|
||||||
|
<li class="has-children" id="athletes">
|
||||||
|
<input type="checkbox" name="athlete-selector" id="athlete-selector">
|
||||||
|
<label for="athlete-selector"><i class="fas fa-users fa-fw"></i> Athletes</label>
|
||||||
|
<ul>
|
||||||
|
{% for member in user|team_members %}
|
||||||
|
<a href={{ request.path|userurl:member }}>
|
||||||
|
<i class="fas fa-user fa-fw"></i>
|
||||||
|
{% if member == rower.user %}
|
||||||
|
•
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{{ member.first_name }} {{ member.last_name }}
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<h1>Workouts</h1>
|
<h1>Workouts</h1>
|
||||||
<ul class="cd-accordion-menu animated">
|
<ul class="cd-accordion-menu animated">
|
||||||
<li id="workouts-list">
|
<li id="workouts-list">
|
||||||
<a href="/rower/list-workouts"><i class="fas fa-clipboard-list fa-fw"></i> Workouts List</a>
|
<a href="/rowers/list-workouts"><i class="fas fa-clipboard-list fa-fw"></i> Workouts List</a>
|
||||||
</li>
|
</li>
|
||||||
<li id="charts">
|
<li id="charts">
|
||||||
<a href="/rowers/list-graphs"><i class="fas fa-chart-pie fa-fw"></i> Charts</a>
|
<a href="/rowers/list-graphs"><i class="fas fa-chart-pie fa-fw"></i> Charts</a>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "newbase.html" %}
|
||||||
{% load staticfiles %}
|
{% load staticfiles %}
|
||||||
{% load rowerfilters %}
|
{% load rowerfilters %}
|
||||||
|
|
||||||
{% block title %}Workouts{% endblock %}
|
{% block title %}Workouts{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block main %}
|
||||||
<script>
|
<script>
|
||||||
function toggle(source) {
|
function toggle(source) {
|
||||||
checkboxes = document.querySelectorAll("input[name='workouts']");
|
checkboxes = document.querySelectorAll("input[name='workouts']");
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
// Get the form fields and hidden div
|
// Get the form fields and hidden div
|
||||||
var checkbox = $("#id_water");
|
var modality = $("#id_modality");
|
||||||
var hidden = $("#id_waterboattype");
|
var hidden = $("#id_waterboattype");
|
||||||
|
|
||||||
|
|
||||||
@@ -29,13 +29,15 @@
|
|||||||
hidden.hide();
|
hidden.hide();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Setup an event listener for when the state of the
|
// Setup an event listener for when the state of the
|
||||||
// checkbox changes.
|
// checkbox changes.
|
||||||
checkbox.change(function() {
|
modality.change(function() {
|
||||||
// Check to see if the checkbox is checked.
|
// Check to see if the checkbox is checked.
|
||||||
// If it is, show the fields and populate the input.
|
// If it is, show the fields and populate the input.
|
||||||
// If not, hide the fields.
|
// If not, hide the fields.
|
||||||
if (checkbox.is(':checked')) {
|
var Value = modality.val();
|
||||||
|
if (Value=='water') {
|
||||||
// Show the hidden fields.
|
// Show the hidden fields.
|
||||||
hidden.show();
|
hidden.show();
|
||||||
} else {
|
} else {
|
||||||
@@ -53,95 +55,23 @@
|
|||||||
// $("#hidden_field").val("");
|
// $("#hidden_field").val("");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
{% if team %}
|
{% if theuser %}
|
||||||
<div class="grid_12 alpha">
|
<h1>Select {{ theuser.first_name }}'s Workouts for BoxPlot</h1>
|
||||||
{% include "teambuttons.html" with teamid=team.id team=team %}
|
{% else %}
|
||||||
</div>
|
<h1>Select {{ user.first_name }}'s Workouts for BoxPlot</h1>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="grid_12 alpha">
|
|
||||||
<div class="grid_4 alpha">
|
|
||||||
{% if theuser %}
|
|
||||||
<h3>{{ theuser.first_name }}'s Workouts</h3>
|
|
||||||
{% else %}
|
|
||||||
<h3>{{ user.first_name }}'s Workouts</h3>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div class="grid_2 prefix_6 omega">
|
|
||||||
{% if user.is_authenticated and user|is_manager %}
|
|
||||||
<div class="grid_2 alpha dropdown">
|
|
||||||
<button class="grid_2 alpha button green small dropbtn">
|
|
||||||
{{ theuser.first_name }} {{ theuser.last_name }}
|
|
||||||
</button>
|
|
||||||
<div class="dropdown-content">
|
|
||||||
{% for member in user|team_members %}
|
|
||||||
<a class="button green small" href="/rowers/user-boxplot-select/user/{{ member.id }}/">{{ member.first_name }} {{ member.last_name }}</a>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="grid_12 alpha">
|
|
||||||
<div class="grid_6 alpha">
|
|
||||||
{% if theuser %}
|
|
||||||
<form enctype="multipart/form-data" action="/rowers/user-boxplot-select/user/{{ theuser.id }}/" method="post">
|
|
||||||
{% else %}
|
|
||||||
<form enctype="multipart/form-data" action="/rowers/user-boxplot-select/" method="post">
|
|
||||||
{% endif %}
|
|
||||||
<div class="grid_4 alpha">
|
|
||||||
|
|
||||||
<table>
|
|
||||||
{{ dateform.as_table }}
|
|
||||||
</table>
|
|
||||||
{% csrf_token %}
|
|
||||||
</div>
|
|
||||||
<div class="grid_2 omega">
|
|
||||||
<input name='daterange' class="button green" type="submit" value="Submit">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{% if theuser %}
|
|
||||||
<form enctype="multipart/form-data" action="/rowers/user-boxplot-select/user/{{ theuser.id }}/" method="post">
|
|
||||||
{% else %}
|
|
||||||
<form enctype="multipart/form-data" action="/rowers/user-boxplot-select/" method="post">
|
|
||||||
{% endif %}
|
|
||||||
<div class="grid_4 alpha">
|
|
||||||
|
|
||||||
<table>
|
|
||||||
{{ optionsform.as_table }}
|
|
||||||
</table>
|
|
||||||
{% csrf_token %}
|
|
||||||
</div>
|
|
||||||
<div class="grid_2 omega">
|
|
||||||
<input name='optionsform' class="button green" type="submit" value="Submit">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid_5 prefix_1 omega">
|
|
||||||
<form id="searchform" action=""
|
|
||||||
method="get" accept-charset="utf-8">
|
|
||||||
<div class="grid_3 prefix_1 alpha">
|
|
||||||
<input class="searchfield" id="searchbox" name="q" type="text" placeholder="Search">
|
|
||||||
</div>
|
|
||||||
<div class="grid_1 omega">
|
|
||||||
<button class="button blue small" type="submit">
|
|
||||||
Search
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<form enctype="multipart/form-data" action="/rowers/user-boxplot/{{ theuser.id }}" method="post">
|
<ul class="main-content">
|
||||||
<div id="workouts_table" class="grid_8 alpha">
|
|
||||||
|
|
||||||
|
<li class="grid_2 maxheight">
|
||||||
|
<form enctype="multipart/form-data" action="/rowers/user-boxplot/{{ theuser.id }}" method="post">
|
||||||
|
|
||||||
{% if workouts %}
|
{% if workouts %}
|
||||||
|
|
||||||
@@ -149,31 +79,70 @@
|
|||||||
<table width="100%" class="listtable">
|
<table width="100%" class="listtable">
|
||||||
{{ form.as_table }}
|
{{ form.as_table }}
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p> No workouts found </p>
|
<p> No workouts found </p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</li>
|
||||||
<div id="form_settings" class="grid_4 alpha">
|
<li class="grid_2">
|
||||||
<p><b>Warning: You are on an experimental part of the site. Use at your own risk.</b></p>
|
<p>Select two or more workouts, set your plot settings below,
|
||||||
<p>Select two or more workouts on the left, set your plot settings below,
|
and press submit
|
||||||
and press submit"</p>
|
</p>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<table>
|
<table>
|
||||||
{{ chartform.as_table }}
|
{{ chartform.as_table }}
|
||||||
</table>
|
</table>
|
||||||
<div class="grid_1 prefix_2 suffix_1">
|
|
||||||
<p>
|
<p>
|
||||||
<input name='workoutselectform' class="button green" type="submit" value="Submit">
|
<input name='workoutselectform' class="button green" type="submit" value="Submit">
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</form>
|
||||||
<div class="grid_4">
|
</li>
|
||||||
|
<li class="grid_2">
|
||||||
|
{% if theuser %}
|
||||||
|
<form enctype="multipart/form-data" action="/rowers/user-boxplot-select/user/{{ theuser.id }}/" method="post">
|
||||||
|
{% else %}
|
||||||
|
<form enctype="multipart/form-data" action="/rowers/user-boxplot-select/" method="post">
|
||||||
|
{% endif %}
|
||||||
|
<table>
|
||||||
|
{{ dateform.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
<input name='daterange' class="button green" type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
<li class="grid_2">
|
||||||
|
{% if theuser %}
|
||||||
|
<form enctype="multipart/form-data" action="/rowers/user-boxplot-select/user/{{ theuser.id }}/" method="post">
|
||||||
|
{% else %}
|
||||||
|
<form enctype="multipart/form-data" action="/rowers/user-boxplot-select/" method="post">
|
||||||
|
{% endif %}
|
||||||
|
<table>
|
||||||
|
{{ optionsform.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
<input name='optionsform' class="button green" type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
<li class="grid_2">
|
||||||
|
<form id="searchform" action=""
|
||||||
|
method="get" accept-charset="utf-8">
|
||||||
|
<input class="searchfield" id="searchbox" name="q" type="text" placeholder="Search">
|
||||||
|
<button class="button blue small" type="submit">
|
||||||
|
Search
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
<p>You can use the date and search forms above to search through all
|
<p>You can use the date and search forms above to search through all
|
||||||
workouts from this team.</p>
|
workouts from this team.</p>
|
||||||
<p>TIP: Agree with your team members to put tags (e.g. '8x500m') in the notes section of
|
<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>
|
your workouts. That makes it easy to search.</p>
|
||||||
</div>
|
</li>
|
||||||
</div>
|
|
||||||
</form>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_analytics.html' %}
|
||||||
|
{% endblock %}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from django.utils import timezone
|
|||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
|
import re
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
from rowers.utils import calculate_age
|
from rowers.utils import calculate_age
|
||||||
from rowers.models import course_length
|
from rowers.models import course_length
|
||||||
@@ -282,3 +283,9 @@ def is_past_due(self):
|
|||||||
@property
|
@property
|
||||||
def is_not_past_due(self):
|
def is_not_past_due(self):
|
||||||
return datetime.date.today() <= self.date
|
return datetime.date.today() <= self.date
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def userurl(path,member):
|
||||||
|
userstring = 'user/%s/' % member.id
|
||||||
|
replaced = re.sub('user\/\d+\/',userstring,path)
|
||||||
|
return replaced
|
||||||
|
|||||||
@@ -5993,24 +5993,42 @@ def user_boxplot_select(request,
|
|||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if 'modalities' in request.session:
|
||||||
|
modalities = request.session['modalities']
|
||||||
|
if len(modalities) > 1:
|
||||||
|
modality = 'all'
|
||||||
|
else:
|
||||||
|
modality = modalities[0]
|
||||||
|
else:
|
||||||
|
modalities = [m[0] for m in types.workouttypes]
|
||||||
|
modality = 'all'
|
||||||
|
|
||||||
if request.method == 'POST' and 'optionsform' in request.POST:
|
if request.method == 'POST' and 'optionsform' in request.POST:
|
||||||
optionsform = StatsOptionsForm(request.POST)
|
optionsform = TrendFlexModalForm(request.POST)
|
||||||
if optionsform.is_valid():
|
if optionsform.is_valid():
|
||||||
workouttypes = []
|
modality = optionsform.cleaned_data['modality']
|
||||||
waterboattype = optionsform.cleaned_data['waterboattype']
|
waterboattype = optionsform.cleaned_data['waterboattype']
|
||||||
|
if modality == 'all':
|
||||||
|
modalities = [m[0] for m in types.workouttypes]
|
||||||
|
else:
|
||||||
|
modalities = [modality]
|
||||||
|
|
||||||
|
if modality != 'water':
|
||||||
|
waterboattype = [b[0] for b in types.boattypes]
|
||||||
|
|
||||||
|
|
||||||
|
if 'rankingonly' in optionsform.cleaned_data:
|
||||||
rankingonly = optionsform.cleaned_data['rankingonly']
|
rankingonly = optionsform.cleaned_data['rankingonly']
|
||||||
for type in types.checktypes:
|
else:
|
||||||
if optionsform.cleaned_data[type]:
|
rankingonly = False
|
||||||
workouttypes.append(type)
|
|
||||||
|
|
||||||
options = {
|
request.session['modalities'] = modalities
|
||||||
'workouttypes':workouttypes,
|
request.session['waterboattype'] = waterboattype
|
||||||
'waterboattype':waterboattype,
|
|
||||||
'rankingonly':rankingonly,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
negtypes = []
|
||||||
request.session['options'] = options
|
for b in types.boattypes:
|
||||||
|
if b[0] not in waterboattype:
|
||||||
|
negtypes.append(b[0])
|
||||||
|
|
||||||
|
|
||||||
startdate = datetime.datetime.combine(startdate,datetime.time())
|
startdate = datetime.datetime.combine(startdate,datetime.time())
|
||||||
@@ -6032,41 +6050,18 @@ def user_boxplot_select(request,
|
|||||||
if b[0] not in waterboattype:
|
if b[0] not in waterboattype:
|
||||||
negtypes.append(b[0])
|
negtypes.append(b[0])
|
||||||
|
|
||||||
if rankingonly:
|
|
||||||
rankingpiece = [True]
|
|
||||||
else:
|
|
||||||
rankingpiece = [True,False]
|
|
||||||
|
|
||||||
waterinclude = False
|
workouts = Workout.objects.filter(user=r,
|
||||||
|
|
||||||
for ttype in types.otwtypes:
|
|
||||||
if ttype in workouttypes:
|
|
||||||
waterinclude = True
|
|
||||||
|
|
||||||
if waterinclude:
|
|
||||||
workoutsw = Workout.objects.filter(user=r,
|
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate,
|
startdatetime__lte=enddate,
|
||||||
workouttype__in=types.otwtypes,
|
workouttype__in=modalities,
|
||||||
rankingpiece__in=rankingpiece,
|
).order_by(
|
||||||
|
"-date", "-starttime"
|
||||||
).exclude(boattype__in=negtypes)
|
).exclude(boattype__in=negtypes)
|
||||||
workouttypes = [w for w in workouttypes if w not in types.otwtypes]
|
# workouttypes = [w for w in workouttypes if w not in types.otwtypes]
|
||||||
|
|
||||||
workoutse = Workout.objects.filter(user=r,
|
if rankingonly:
|
||||||
startdatetime__gte=startdate,
|
workouts = [w for w in workouts if w.rankingpiece]
|
||||||
startdatetime__lte=enddate,
|
|
||||||
workouttype__in=workouttypes,
|
|
||||||
rankingpiece__in=rankingpiece)
|
|
||||||
|
|
||||||
if waterinclude:
|
|
||||||
workouts = workoutse | workoutsw
|
|
||||||
workouts = workouts.distinct().order_by("-date", "-starttime")
|
|
||||||
else:
|
|
||||||
workouts = workoutse.order_by("-date","-starttime")
|
|
||||||
|
|
||||||
if waterinclude:
|
|
||||||
for ttype in types.otwtypes:
|
|
||||||
workouttypes.append(ttype)
|
|
||||||
|
|
||||||
query = request.GET.get('q')
|
query = request.GET.get('q')
|
||||||
if query:
|
if query:
|
||||||
@@ -6082,19 +6077,11 @@ def user_boxplot_select(request,
|
|||||||
form.fields["workouts"].queryset = workouts
|
form.fields["workouts"].queryset = workouts
|
||||||
|
|
||||||
chartform = BoxPlotChoiceForm()
|
chartform = BoxPlotChoiceForm()
|
||||||
# set options form correctly
|
optionsform = TrendFlexModalForm(initial={
|
||||||
initial = {}
|
'modality':modality,
|
||||||
initial['waterboattype'] = waterboattype
|
'waterboattype':waterboattype,
|
||||||
initial['rankingonly'] = rankingonly
|
'rankingonly':rankingonly,
|
||||||
|
})
|
||||||
for wtype in types.checktypes:
|
|
||||||
if wtype in workouttypes:
|
|
||||||
initial[wtype] = True
|
|
||||||
else:
|
|
||||||
initial[wtype] = False
|
|
||||||
|
|
||||||
|
|
||||||
optionsform = StatsOptionsForm(initial=initial)
|
|
||||||
|
|
||||||
messages.info(request,successmessage)
|
messages.info(request,successmessage)
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
@@ -6109,8 +6096,10 @@ def user_boxplot_select(request,
|
|||||||
'dateform':dateform,
|
'dateform':dateform,
|
||||||
'startdate':startdate,
|
'startdate':startdate,
|
||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
|
'rower':r,
|
||||||
'theuser':user,
|
'theuser':user,
|
||||||
'form':form,
|
'form':form,
|
||||||
|
'active':'nav-analysis',
|
||||||
'chartform':chartform,
|
'chartform':chartform,
|
||||||
'optionsform':optionsform,
|
'optionsform':optionsform,
|
||||||
'teams':get_my_teams(request.user),
|
'teams':get_my_teams(request.user),
|
||||||
|
|||||||
Reference in New Issue
Block a user