menu_analytics and boxplot-select
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
<h1>Analysis</h1>
|
||||
<ul class="cd-accordion-menu animated">
|
||||
<li class="has-children" id="fitness">
|
||||
@@ -65,3 +67,27 @@
|
||||
<i class="fas fa-flask fa-fw"></i> Laboratory</a>
|
||||
</li>
|
||||
</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>
|
||||
<ul class="cd-accordion-menu animated">
|
||||
<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 id="charts">
|
||||
<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 rowerfilters %}
|
||||
|
||||
{% block title %}Workouts{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% block main %}
|
||||
<script>
|
||||
function toggle(source) {
|
||||
checkboxes = document.querySelectorAll("input[name='workouts']");
|
||||
@@ -18,7 +18,7 @@
|
||||
$(function() {
|
||||
|
||||
// Get the form fields and hidden div
|
||||
var checkbox = $("#id_water");
|
||||
var modality = $("#id_modality");
|
||||
var hidden = $("#id_waterboattype");
|
||||
|
||||
|
||||
@@ -28,14 +28,16 @@
|
||||
|
||||
hidden.hide();
|
||||
|
||||
|
||||
|
||||
// Setup an event listener for when the state of the
|
||||
// checkbox changes.
|
||||
checkbox.change(function() {
|
||||
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.
|
||||
if (checkbox.is(':checked')) {
|
||||
// If not, hide the fields.
|
||||
var Value = modality.val();
|
||||
if (Value=='water') {
|
||||
// Show the hidden fields.
|
||||
hidden.show();
|
||||
} else {
|
||||
@@ -53,95 +55,23 @@
|
||||
// $("#hidden_field").val("");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
{% if team %}
|
||||
<div class="grid_12 alpha">
|
||||
{% include "teambuttons.html" with teamid=team.id team=team %}
|
||||
</div>
|
||||
{% if theuser %}
|
||||
<h1>Select {{ theuser.first_name }}'s Workouts for BoxPlot</h1>
|
||||
{% else %}
|
||||
<h1>Select {{ user.first_name }}'s Workouts for BoxPlot</h1>
|
||||
{% 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">
|
||||
<div id="workouts_table" class="grid_8 alpha">
|
||||
<ul class="main-content">
|
||||
|
||||
<li class="grid_2 maxheight">
|
||||
<form enctype="multipart/form-data" action="/rowers/user-boxplot/{{ theuser.id }}" method="post">
|
||||
|
||||
{% if workouts %}
|
||||
|
||||
@@ -149,31 +79,70 @@
|
||||
<table width="100%" class="listtable">
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% else %}
|
||||
<p> No workouts found </p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="form_settings" class="grid_4 alpha">
|
||||
<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 on the left, set your plot settings below,
|
||||
and press submit"</p>
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
{{ chartform.as_table }}
|
||||
</table>
|
||||
<div class="grid_1 prefix_2 suffix_1">
|
||||
{% else %}
|
||||
<p> No workouts found </p>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<p>Select two or more workouts, set your plot settings below,
|
||||
and press submit
|
||||
</p>
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
{{ chartform.as_table }}
|
||||
</table>
|
||||
<p>
|
||||
<input name='workoutselectform' class="button green" type="submit" value="Submit">
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_4">
|
||||
<p>You can use the date and search forms above 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>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</p>
|
||||
</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>
|
||||
{{ 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
|
||||
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>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_analytics.html' %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -5,6 +5,7 @@ from django.utils import timezone
|
||||
import dateutil.parser
|
||||
import json
|
||||
import datetime
|
||||
import re
|
||||
register = template.Library()
|
||||
from rowers.utils import calculate_age
|
||||
from rowers.models import course_length
|
||||
@@ -282,3 +283,9 @@ def is_past_due(self):
|
||||
@property
|
||||
def is_not_past_due(self):
|
||||
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
|
||||
|
||||
111
rowers/views.py
111
rowers/views.py
@@ -5993,24 +5993,42 @@ def user_boxplot_select(request,
|
||||
'enddate':enddate,
|
||||
})
|
||||
|
||||
if request.method == 'POST' and 'optionsform' in request.POST:
|
||||
optionsform = StatsOptionsForm(request.POST)
|
||||
if optionsform.is_valid():
|
||||
workouttypes = []
|
||||
waterboattype = optionsform.cleaned_data['waterboattype']
|
||||
rankingonly = optionsform.cleaned_data['rankingonly']
|
||||
for type in types.checktypes:
|
||||
if optionsform.cleaned_data[type]:
|
||||
workouttypes.append(type)
|
||||
|
||||
options = {
|
||||
'workouttypes':workouttypes,
|
||||
'waterboattype':waterboattype,
|
||||
'rankingonly':rankingonly,
|
||||
}
|
||||
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'
|
||||
|
||||
|
||||
request.session['options'] = options
|
||||
if request.method == 'POST' and 'optionsform' in request.POST:
|
||||
optionsform = TrendFlexModalForm(request.POST)
|
||||
if optionsform.is_valid():
|
||||
modality = optionsform.cleaned_data['modality']
|
||||
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']
|
||||
else:
|
||||
rankingonly = False
|
||||
|
||||
request.session['modalities'] = modalities
|
||||
request.session['waterboattype'] = waterboattype
|
||||
|
||||
negtypes = []
|
||||
for b in types.boattypes:
|
||||
if b[0] not in waterboattype:
|
||||
negtypes.append(b[0])
|
||||
|
||||
|
||||
startdate = datetime.datetime.combine(startdate,datetime.time())
|
||||
@@ -6032,42 +6050,19 @@ def user_boxplot_select(request,
|
||||
if b[0] not in waterboattype:
|
||||
negtypes.append(b[0])
|
||||
|
||||
if rankingonly:
|
||||
rankingpiece = [True]
|
||||
else:
|
||||
rankingpiece = [True,False]
|
||||
|
||||
waterinclude = False
|
||||
|
||||
for ttype in types.otwtypes:
|
||||
if ttype in workouttypes:
|
||||
waterinclude = True
|
||||
|
||||
if waterinclude:
|
||||
workoutsw = Workout.objects.filter(user=r,
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate,
|
||||
workouttype__in=types.otwtypes,
|
||||
rankingpiece__in=rankingpiece,
|
||||
).exclude(boattype__in=negtypes)
|
||||
workouttypes = [w for w in workouttypes if w not in types.otwtypes]
|
||||
|
||||
workoutse = Workout.objects.filter(user=r,
|
||||
workouts = Workout.objects.filter(user=r,
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate,
|
||||
workouttype__in=workouttypes,
|
||||
rankingpiece__in=rankingpiece)
|
||||
workouttype__in=modalities,
|
||||
).order_by(
|
||||
"-date", "-starttime"
|
||||
).exclude(boattype__in=negtypes)
|
||||
# workouttypes = [w for w in workouttypes if w not in types.otwtypes]
|
||||
|
||||
if waterinclude:
|
||||
workouts = workoutse | workoutsw
|
||||
workouts = workouts.distinct().order_by("-date", "-starttime")
|
||||
else:
|
||||
workouts = workoutse.order_by("-date","-starttime")
|
||||
if rankingonly:
|
||||
workouts = [w for w in workouts if w.rankingpiece]
|
||||
|
||||
if waterinclude:
|
||||
for ttype in types.otwtypes:
|
||||
workouttypes.append(ttype)
|
||||
|
||||
query = request.GET.get('q')
|
||||
if query:
|
||||
query_list = query.split()
|
||||
@@ -6082,19 +6077,11 @@ def user_boxplot_select(request,
|
||||
form.fields["workouts"].queryset = workouts
|
||||
|
||||
chartform = BoxPlotChoiceForm()
|
||||
# set options form correctly
|
||||
initial = {}
|
||||
initial['waterboattype'] = waterboattype
|
||||
initial['rankingonly'] = rankingonly
|
||||
|
||||
for wtype in types.checktypes:
|
||||
if wtype in workouttypes:
|
||||
initial[wtype] = True
|
||||
else:
|
||||
initial[wtype] = False
|
||||
|
||||
|
||||
optionsform = StatsOptionsForm(initial=initial)
|
||||
optionsform = TrendFlexModalForm(initial={
|
||||
'modality':modality,
|
||||
'waterboattype':waterboattype,
|
||||
'rankingonly':rankingonly,
|
||||
})
|
||||
|
||||
messages.info(request,successmessage)
|
||||
messages.error(request,message)
|
||||
@@ -6109,8 +6096,10 @@ def user_boxplot_select(request,
|
||||
'dateform':dateform,
|
||||
'startdate':startdate,
|
||||
'enddate':enddate,
|
||||
'rower':r,
|
||||
'theuser':user,
|
||||
'form':form,
|
||||
'active':'nav-analysis',
|
||||
'chartform':chartform,
|
||||
'optionsform':optionsform,
|
||||
'teams':get_my_teams(request.user),
|
||||
|
||||
Reference in New Issue
Block a user