start of multiflex
This commit is contained in:
@@ -69,7 +69,27 @@ watermarkw = 184
|
|||||||
watermarkh = 35
|
watermarkh = 35
|
||||||
watermarkanchor = 'bottom_right'
|
watermarkanchor = 'bottom_right'
|
||||||
|
|
||||||
|
def errorbar(fig, x, y, xerr=None, yerr=None, color='red',
|
||||||
|
point_kwargs={}, error_kwargs={}):
|
||||||
|
|
||||||
|
fig.circle(x, y, color=color, **point_kwargs)
|
||||||
|
|
||||||
|
if xerr:
|
||||||
|
x_err_x = []
|
||||||
|
x_err_y = []
|
||||||
|
for px, py, err in zip(x, y, xerr):
|
||||||
|
x_err_x.append((px - err, px + err))
|
||||||
|
x_err_y.append((py, py))
|
||||||
|
fig.multi_line(x_err_x, x_err_y, color=color, **error_kwargs)
|
||||||
|
|
||||||
|
if yerr:
|
||||||
|
y_err_x = []
|
||||||
|
y_err_y = []
|
||||||
|
for px, py, err in zip(x, y, yerr):
|
||||||
|
y_err_x.append((px, px))
|
||||||
|
y_err_y.append((py - err, py + err))
|
||||||
|
fig.multi_line(y_err_x, y_err_y, color=color, **error_kwargs)
|
||||||
|
|
||||||
def tailwind(bearing,vwind,winddir):
|
def tailwind(bearing,vwind,winddir):
|
||||||
""" Calculates head-on head/tailwind in direction of rowing
|
""" Calculates head-on head/tailwind in direction of rowing
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@
|
|||||||
Analyse power vs piece duration to make predictions.
|
Analyse power vs piece duration to make predictions.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2 suffix_2 omega">
|
<div class="grid_2">
|
||||||
<p>
|
<p>
|
||||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||||
<a class="button blue small" href="/rowers/team-compare-select/team/0/">Multi Compare</a>
|
<a class="button blue small" href="/rowers/team-compare-select/team/0/">Multi Compare</a>
|
||||||
@@ -107,6 +107,18 @@
|
|||||||
Compare many workouts
|
Compare many workouts
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="grid_2 omega">
|
||||||
|
<p>
|
||||||
|
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||||
|
<a class="button blue small" href="/rowers/user-multiflex-select">Multi Flex</a>
|
||||||
|
{% else %}
|
||||||
|
<a class="button blue small" href="/rowers/promembership">Multi Flex</a>
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Select workouts and make X-Y charts of averages over various metrics
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
118
rowers/templates/user_multiflex_select.html
Normal file
118
rowers/templates/user_multiflex_select.html
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block title %}Workouts{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
{% if team %}
|
||||||
|
<div class="grid_12 alpha">
|
||||||
|
{% include "teambuttons.html" with teamid=team.id team=team %}
|
||||||
|
</div>
|
||||||
|
{% 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">
|
||||||
|
Change Rower
|
||||||
|
</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_4 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 %}
|
||||||
|
|
||||||
|
<table>
|
||||||
|
{{ dateform.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
</div>
|
||||||
|
<div class="grid_2">
|
||||||
|
<input name='daterange' class="button green" type="submit" value="Submit"> </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">
|
||||||
|
|
||||||
|
|
||||||
|
{% if workouts %}
|
||||||
|
|
||||||
|
<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 %}
|
||||||
|
</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">
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -129,6 +129,10 @@ urlpatterns = [
|
|||||||
url(r'^user-boxplot-select/user/(?P<userid>\d+)/$',views.user_boxplot_select),
|
url(r'^user-boxplot-select/user/(?P<userid>\d+)/$',views.user_boxplot_select),
|
||||||
url(r'^user-boxplot-select/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.user_boxplot_select),
|
url(r'^user-boxplot-select/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.user_boxplot_select),
|
||||||
url(r'^user-boxplot-select/$',views.user_boxplot_select),
|
url(r'^user-boxplot-select/$',views.user_boxplot_select),
|
||||||
|
url(r'^user-multiflex-select/user/(?P<userid>\d+)/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.user_multiflex_select),
|
||||||
|
url(r'^user-multiflex-select/user/(?P<userid>\d+)/$',views.user_multiflex_select),
|
||||||
|
url(r'^user-multiflex-select/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.user_multiflex_select),
|
||||||
|
url(r'^user-multiflex-select/$',views.user_multiflex_select),
|
||||||
url(r'^list-graphs/$',views.graphs_view),
|
url(r'^list-graphs/$',views.graphs_view),
|
||||||
url(r'^(?P<theuser>\d+)/ote-bests/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.rankings_view),
|
url(r'^(?P<theuser>\d+)/ote-bests/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.rankings_view),
|
||||||
url(r'^(?P<theuser>\d+)/ote-bests/(?P<deltadays>\d+)$',views.rankings_view),
|
url(r'^(?P<theuser>\d+)/ote-bests/(?P<deltadays>\d+)$',views.rankings_view),
|
||||||
|
|||||||
@@ -3324,6 +3324,97 @@ def multi_compare_view(request):
|
|||||||
url = reverse(workouts_view)
|
url = reverse(workouts_view)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
# Box plots
|
||||||
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
|
def user_multiflex_select(request,
|
||||||
|
startdatestring="",
|
||||||
|
enddatestring="",
|
||||||
|
message='',
|
||||||
|
successmessage='',
|
||||||
|
startdate=timezone.now()-datetime.timedelta(days=30),
|
||||||
|
enddate=timezone.now()+datetime.timedelta(days=1),
|
||||||
|
userid=0):
|
||||||
|
|
||||||
|
if userid == 0:
|
||||||
|
user = request.user
|
||||||
|
else:
|
||||||
|
user = User.objects.get(id=userid)
|
||||||
|
|
||||||
|
|
||||||
|
r = getrower(user)
|
||||||
|
|
||||||
|
if 'startdate' in request.session:
|
||||||
|
startdate = iso8601.parse_date(request.session['startdate'])
|
||||||
|
|
||||||
|
|
||||||
|
if 'enddate' in request.session:
|
||||||
|
enddate = iso8601.parse_date(request.session['enddate'])
|
||||||
|
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
dateform = DateRangeForm(request.POST)
|
||||||
|
if dateform.is_valid():
|
||||||
|
startdate = dateform.cleaned_data['startdate']
|
||||||
|
enddate = dateform.cleaned_data['enddate']
|
||||||
|
else:
|
||||||
|
dateform = DateRangeForm(initial={
|
||||||
|
'startdate':startdate,
|
||||||
|
'enddate':enddate,
|
||||||
|
})
|
||||||
|
|
||||||
|
startdate = datetime.datetime.combine(startdate,datetime.time())
|
||||||
|
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
|
||||||
|
enddate = enddate+datetime.timedelta(days=1)
|
||||||
|
|
||||||
|
if startdatestring:
|
||||||
|
startdate = iso8601.parse_date(startdatestring)
|
||||||
|
if enddatestring:
|
||||||
|
enddate = iso8601.parse_date(enddatestring)
|
||||||
|
|
||||||
|
if enddate < startdate:
|
||||||
|
s = enddate
|
||||||
|
enddate = startdate
|
||||||
|
startdate = s
|
||||||
|
|
||||||
|
|
||||||
|
workouts = Workout.objects.filter(user=r,
|
||||||
|
startdatetime__gte=startdate,
|
||||||
|
startdatetime__lte=enddate).order_by("-date", "-starttime")
|
||||||
|
|
||||||
|
query = request.GET.get('q')
|
||||||
|
if query:
|
||||||
|
query_list = query.split()
|
||||||
|
workouts = workouts.filter(
|
||||||
|
reduce(operator.and_,
|
||||||
|
(Q(name__icontains=q) for q in query_list)) |
|
||||||
|
reduce(operator.and_,
|
||||||
|
(Q(notes__icontains=q) for q in query_list))
|
||||||
|
)
|
||||||
|
|
||||||
|
form = WorkoutMultipleCompareForm()
|
||||||
|
form.fields["workouts"].queryset = workouts
|
||||||
|
|
||||||
|
chartform = BoxPlotChoiceForm()
|
||||||
|
|
||||||
|
messages.info(request,successmessage)
|
||||||
|
messages.error(request,message)
|
||||||
|
|
||||||
|
startdatestring = startdate.strftime('%Y-%m-%d')
|
||||||
|
enddatestring = enddate.strftime('%Y-%m-%d')
|
||||||
|
request.session['startdate'] = startdatestring
|
||||||
|
request.session['enddate'] = enddatestring
|
||||||
|
|
||||||
|
return render(request, 'user_boxplot_select.html',
|
||||||
|
{'workouts': workouts,
|
||||||
|
'dateform':dateform,
|
||||||
|
'startdate':startdate,
|
||||||
|
'enddate':enddate,
|
||||||
|
'theuser':user,
|
||||||
|
'form':form,
|
||||||
|
'chartform':chartform,
|
||||||
|
'teams':get_my_teams(request.user),
|
||||||
|
})
|
||||||
|
|
||||||
# Box plots
|
# Box plots
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
def user_boxplot_select(request,
|
def user_boxplot_select(request,
|
||||||
|
|||||||
Reference in New Issue
Block a user