Merge branch 'release/v5.11'
This commit is contained in:
@@ -158,6 +158,72 @@ def filter_df(datadf, fieldname, value, largerthan=True):
|
||||
|
||||
return datadf
|
||||
|
||||
# joins workouts
|
||||
def join_workouts(r,ids,title='Joined Workout',
|
||||
parent=None,
|
||||
setprivate=False,
|
||||
forceunit='lbs'):
|
||||
|
||||
message = None
|
||||
|
||||
summary = ''
|
||||
if parent:
|
||||
oarlength = parent.oarlength
|
||||
inboard = parent.inboard
|
||||
workouttype = parent.workouttype
|
||||
notes = parent.notes
|
||||
summary = parent.summary
|
||||
if parent.privacy == 'hidden':
|
||||
makeprivate = True
|
||||
else:
|
||||
makeprivate = False
|
||||
|
||||
startdatetime = parent.startdatetime
|
||||
else:
|
||||
oarlength = 2.89
|
||||
inboard = 0.88
|
||||
workouttype = 'rower'
|
||||
notes = ''
|
||||
summary = ''
|
||||
makeprivate = False
|
||||
startdatetime = timezone.now()
|
||||
|
||||
if setprivate == True and makeprivate == False:
|
||||
makeprivate = True
|
||||
elif setprivate == False and makeprivate == True:
|
||||
makeprivate = False
|
||||
|
||||
|
||||
# reorder in chronological order
|
||||
ws = Workout.objects.filter(id__in=ids).order_by("date", "starttime")
|
||||
files = [w.csvfilename for w in ws]
|
||||
|
||||
row = rdata(files[0])
|
||||
|
||||
files = files[1:]
|
||||
|
||||
while len(files):
|
||||
row2 = rdata(files[0])
|
||||
if row2 != 0:
|
||||
row = row+row2
|
||||
files = files[1:]
|
||||
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
csvfilename = 'media/df_' + timestr + '.csv'
|
||||
|
||||
row.write_csv(csvfilename,gzip=True)
|
||||
id, message = save_workout_database(csvfilename, r,
|
||||
workouttype=workouttype,
|
||||
title=title,
|
||||
notes=notes,
|
||||
oarlength=oarlength,
|
||||
inboard=inboard,
|
||||
makeprivate=makeprivate,
|
||||
dosmooth=False,
|
||||
consistencychecks=False)
|
||||
|
||||
return (id, message)
|
||||
|
||||
|
||||
def df_resample(datadf):
|
||||
# time stamps must be in seconds
|
||||
@@ -801,6 +867,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
pytz.timezone(timezone_str)
|
||||
).strftime('%H:%M:%S')
|
||||
|
||||
|
||||
if makeprivate:
|
||||
privacy = 'hidden'
|
||||
else:
|
||||
|
||||
@@ -521,7 +521,11 @@ class ChartParamChoiceForm(forms.Form):
|
||||
|
||||
formaxlabels.pop('time')
|
||||
metricchoices = list(sorted(formaxlabels.items(), key = lambda x:x[1]))
|
||||
|
||||
|
||||
class WorkoutJoinParamForm(forms.Form):
|
||||
workout_name = forms.CharField(required = True, initial = 'Joined Workout')
|
||||
set_private = forms.BooleanField(initial=False, required = False)
|
||||
|
||||
class FusionMetricChoiceForm(ModelForm):
|
||||
class Meta:
|
||||
model = Workout
|
||||
|
||||
@@ -2475,9 +2475,12 @@ def interactive_flex_chart2(id=0,promember=0,
|
||||
slider_work_max = Slider(start=0.0, end=1500,value=1500.0, step=10,
|
||||
title="Max Work per Stroke",callback=callback)
|
||||
callback.args["maxwork"] = slider_work_max
|
||||
|
||||
distmax = 100+100*int(rowdata['distance'].max()/100.)
|
||||
|
||||
|
||||
try:
|
||||
distmax = 100+100*int(rowdata['distance'].max()/100.)
|
||||
except KeyError:
|
||||
distmax = 100
|
||||
|
||||
slider_dist_min = Slider(start=0,end=distmax,value=0,step=1,
|
||||
title="Min Distance",callback=callback)
|
||||
callback.args["mindist"] = slider_dist_min
|
||||
|
||||
@@ -4,7 +4,7 @@ import sys
|
||||
import os
|
||||
|
||||
import zipfile
|
||||
|
||||
import re
|
||||
import time
|
||||
from time import strftime
|
||||
|
||||
@@ -95,6 +95,24 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
|
||||
return workoutid
|
||||
|
||||
def get_from_address(message):
|
||||
|
||||
from_address = message.from_address[0].lower()
|
||||
|
||||
if message.encoded:
|
||||
body = message.text.splitlines()
|
||||
else:
|
||||
body = message.get_body().splitlines()
|
||||
|
||||
first_line = body[0].lower()
|
||||
|
||||
if "quiske" in first_line:
|
||||
match = re.search(r'[\w\.-]+@[\w\.-]+', first_line)
|
||||
return match.group(0)
|
||||
|
||||
return from_address
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
@@ -131,7 +149,9 @@ class Command(BaseCommand):
|
||||
|
||||
|
||||
uploadoptions = uploads.upload_options(body)
|
||||
from_address = message.from_address[0].lower()
|
||||
|
||||
from_address = get_from_address(message)
|
||||
|
||||
name = message.subject
|
||||
# get a list of users
|
||||
# theusers = User.objects.filter(email=from_address)
|
||||
|
||||
@@ -6,198 +6,217 @@
|
||||
|
||||
{% block content %}
|
||||
<div id="workouts" class="grid_6 alpha">
|
||||
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<h1>{{ workout.name }} - Advanced</h1>
|
||||
{% if user.rower.rowerplan == 'basic' %}
|
||||
<p>This is a preview of the page with advanced functionality for Pro users.
|
||||
See
|
||||
<a href="/rowers/promembership">the page about Pro membership</a> for more information and to sign up for Pro Membership</a>
|
||||
{% endif %}
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/workflow">Workflow View</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/export">Export</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<table width=100%>
|
||||
<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>
|
||||
<th>Public link to this workout</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
|
||||
<td>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 alpha">
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/compare/{{ workout.id }}">Compare Workouts</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership/">Compare Workouts</a>
|
||||
<div class="grid_6 alpha">
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<h1>{{ workout.name }} - Advanced</h1>
|
||||
{% if user.rower.rowerplan == 'basic' %}
|
||||
<p>This is a preview of the page with advanced functionality for Pro users.
|
||||
See
|
||||
<a href="/rowers/promembership">the page about Pro membership</a>
|
||||
for more information and to sign up for Pro Membership</a></p>
|
||||
{% endif %}
|
||||
<p>
|
||||
Compare this workout to other workouts. Plot HR, SPM, or pace vs time or distance for the two workouts.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/flexchart">
|
||||
Flexible Interactive Plot
|
||||
</a>
|
||||
<p>
|
||||
Flexible Interactive plot. Pick your own X and Y axis parameters.
|
||||
</p>
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/workflow">Workflow View</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>
|
||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/export">Export</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid_2 omega tooltip">
|
||||
<p>
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<table width=100%>
|
||||
<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>
|
||||
<th>Public link to this workout</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
|
||||
<td>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 alpha">
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/editintervals">Edit Intervals</a>
|
||||
<a class="button blue small" href="/rowers/workout/compare/{{ workout.id }}">Compare Workouts</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Edit Intervals</a>
|
||||
<a class="button blue small" href="/rowers/promembership/">Compare Workouts</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<span class="tooltiptext">Enter or change the interval and summary data for your workout</span>
|
||||
|
||||
<p>
|
||||
Enter or change the interval and summary data for your workout
|
||||
</p>
|
||||
<p>
|
||||
Compare this workout to other workouts. Plot HR, SPM, or pace vs time or distance for the two workouts.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/flexchart">
|
||||
Flexible Interactive Plot
|
||||
</a>
|
||||
<p>
|
||||
Flexible Interactive plot. Pick your own X and Y axis parameters.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid_2 omega tooltip">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/editintervals">Edit Intervals</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Edit Intervals</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<span class="tooltiptext">Enter or change the interval and summary data for your workout</span>
|
||||
|
||||
<p>
|
||||
Enter or change the interval and summary data for your workout
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/adddistanceplot2">Dist Metrics Plot</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Dist Metrics Plot</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Various advanced stroke metrics plotted versus distance.
|
||||
</p>
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/adddistanceplot2">Dist Metrics Plot</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Dist Metrics Plot</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Various advanced stroke metrics plotted versus distance.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/addtimeplot2">Time Metrics Plot</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Time Metrics Plot</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Various advanced stroke metrics plotted versus time.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/histo">Power Histogram</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Power Histogram</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Plot the Power Histogram of this workout
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/addtimeplot2">Time Metrics Plot</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Time Metrics Plot</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Various advanced stroke metrics plotted versus time.
|
||||
</p>
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workouts-join-select">Glue</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Glue</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Glue multiple workouts together (into one workout). For example, to combine separately recorded intervals.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/fusion/{{ workout.id }}/">Sensor Fusion</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Sensor Fusion</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Merge data from another source into this workout
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/split">Split Workout</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Split Workout</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Split workout into two seperate workouts
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/interactiveplot">Big Interactive Plot</a>
|
||||
</p>
|
||||
<p>
|
||||
See (and save) the big interactive plot
|
||||
</p>
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/interactiveplot">Big Interactive Plot</a>
|
||||
</p>
|
||||
<p>
|
||||
See (and save) the big interactive plot
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/histo">Power Histogram</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Dist Metrics Plot</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Plot the Power Histogram of this workout
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/fusion/{{ workout.id }}/">Sensor Fusion</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Sensor Fusion</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Merge data from another source into this workout
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/split">Split Workout</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Split Workout</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Split workout into two seperate workouts
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="advancedplots" class="grid_6 omega">
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||
<script async="true" type="text/javascript">
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
|
||||
{{ interactiveplot |safe }}
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||
<script async="true" type="text/javascript">
|
||||
Bokeh.set_log_level("info");
|
||||
</script>
|
||||
|
||||
{{ interactiveplot |safe }}
|
||||
|
||||
<script>
|
||||
// Set things up to resize the plot on a window resize. You can play with
|
||||
// the arguments of resize_width_height() to change the plot's behavior.
|
||||
var plot_resize_setup = function () {
|
||||
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
||||
var plot = Bokeh.index[plotid];
|
||||
var plotresizer = function() {
|
||||
// arguments: use width, use height, maintain aspect ratio
|
||||
plot.resize_width_height(true, true, true);
|
||||
};
|
||||
window.addEventListener('resize', plotresizer);
|
||||
plotresizer();
|
||||
};
|
||||
window.addEventListener('load', plot_resize_setup);
|
||||
// Set things up to resize the plot on a window resize. You can play with
|
||||
// the arguments of resize_width_height() to change the plot's behavior.
|
||||
var plot_resize_setup = function () {
|
||||
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
||||
var plot = Bokeh.index[plotid];
|
||||
var plotresizer = function() {
|
||||
// arguments: use width, use height, maintain aspect ratio
|
||||
plot.resize_width_height(true, true, true);
|
||||
};
|
||||
window.addEventListener('resize', plotresizer);
|
||||
plotresizer();
|
||||
};
|
||||
window.addEventListener('load', plot_resize_setup);
|
||||
</script>
|
||||
<style>
|
||||
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
||||
html, body {height: 100%; margin:5px;}
|
||||
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
||||
html, body {height: 100%; margin:5px;}
|
||||
</style>
|
||||
|
||||
|
||||
<div id="interactiveplot" class="grid_6 omega">
|
||||
{{ the_div |safe }}
|
||||
</div>
|
||||
|
||||
|
||||
<div id="interactiveplot" class="grid_6 omega">
|
||||
{{ the_div |safe }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -187,14 +187,18 @@
|
||||
</div>
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/interactiveplot">Big Interactive Plot</a>
|
||||
</p>
|
||||
<p>
|
||||
See (and save) the big interactive plot
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
<a class="button blue small" href="/rowers/workouts-join-select">Glue</a>
|
||||
{% else %}
|
||||
<a class="button blue small" href="/rowers/promembership">Glue</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
Glue multiple workouts together (into one workout). For example, to combine separately recorded intervals.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
|
||||
@@ -220,6 +224,17 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
<div class="grid_2 alpha">
|
||||
<p>
|
||||
<a class="button blue small" href="/rowers/workout/{{ workout.id }}/interactiveplot">Big Interactive Plot</a>
|
||||
</p>
|
||||
<p>
|
||||
See (and save) the big interactive plot
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="advancedplots" class="grid_6 omega">
|
||||
|
||||
@@ -195,7 +195,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid_5 alpha">
|
||||
<div class="grid_6 alpha">
|
||||
{% if rankingonly and not team %}
|
||||
<div class="grid_2 prefix_1 alpha">
|
||||
<a class="button small green" href="/rowers/list-workouts">All Workouts</a>
|
||||
@@ -205,6 +205,9 @@
|
||||
<a class="button small green" href="/rowers/list-workouts/ranking">Ranking Pieces Only</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="grid_2 suffix_1 omega">
|
||||
<a class="button small gray" href="/rowers/workouts-join-select">Glue Workouts</a>
|
||||
</div>
|
||||
<p> </p>
|
||||
{% if team %}
|
||||
<form id="searchform" action="/rowers/list-workouts/team/{{ team.id }}/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}"
|
||||
@@ -223,7 +226,7 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="grid_2 prefix_1 omega">
|
||||
<div class="grid_2 omega">
|
||||
<span class="button gray small">
|
||||
{% if workouts.has_previous %}
|
||||
{% if request.GET.q %}
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
<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>
|
||||
and press submit</p>
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
{{ chartform.as_table }}
|
||||
|
||||
167
rowers/templates/workout_join_select.html
Normal file
167
rowers/templates/workout_join_select.html
Normal file
@@ -0,0 +1,167 @@
|
||||
{% 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>
|
||||
<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();
|
||||
|
||||
|
||||
|
||||
// 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>
|
||||
|
||||
|
||||
<div class="grid_12 alpha">
|
||||
{% include "teambuttons.html" with teamid=team.id team=team %}
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<h3>{{ team.name }} Team Workouts</h3>
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<div class="grid_6 alpha">
|
||||
|
||||
{% if team %}
|
||||
<form enctype="multipart/form-data" action="/rowers/workouts-join-select/team/{{ team.id }}/" method="post">
|
||||
{% else %}
|
||||
<form enctype="multipart/form-data" action="/rowers/workouts-join-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 team %}
|
||||
<form enctype="multipart/form-data" action="/rowers/workouts-join-select/team/{{ team.id }}/" method="post">
|
||||
{% else %}
|
||||
<form enctype="multipart/form-data" action="/rowers/workouts-join-select/" method="post">
|
||||
{% endif %}
|
||||
<div class="grid_4 alpha">
|
||||
<table>
|
||||
{{ modalityform.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<input name='modalityform' class="button green" type="submit" value="Submit">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="grid_5 prefix_1 omega">
|
||||
{% if team %}
|
||||
<form id="searchform" action="/rowers/workouts-join-select/team/{{ team.id }}/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}"
|
||||
method="get" accept-charset="utf-8">
|
||||
{% else %}
|
||||
<form id="searchform" action="/rowers/workouts-join-select/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}"
|
||||
method="get" accept-charset="utf-8">
|
||||
{% endif %}
|
||||
<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/workouts-join" 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,
|
||||
and press submit</p>
|
||||
<table>
|
||||
{{ joinparamform.as_table }}
|
||||
</table>
|
||||
<div class="grid_1 prefix_2 suffix_1">
|
||||
<p>
|
||||
{% csrf_token %}
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -131,6 +131,11 @@ urlpatterns = [
|
||||
url(r'^team-compare-select/team/(?P<teamid>\d+)/$',views.team_comparison_select),
|
||||
url(r'^team-compare-select/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.team_comparison_select),
|
||||
url(r'^team-compare-select/$',views.team_comparison_select),
|
||||
url(r'^workouts-join-select/team/(?P<teamid>\d+)/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.workouts_join_select),
|
||||
url(r'^workouts-join$',views.workouts_join_view),
|
||||
url(r'^workouts-join-select/team/(?P<teamid>\d+)/$',views.workouts_join_select),
|
||||
url(r'^workouts-join-select/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.workouts_join_select),
|
||||
url(r'^workouts-join-select/$',views.workouts_join_select),
|
||||
url(r'^user-boxplot-select/user/(?P<userid>\d+)/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',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),
|
||||
|
||||
216
rowers/views.py
216
rowers/views.py
@@ -46,7 +46,7 @@ from rowers.forms import (
|
||||
RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm,
|
||||
UpdateStreamForm,WorkoutMultipleCompareForm,ChartParamChoiceForm,
|
||||
FusionMetricChoiceForm,BoxPlotChoiceForm,MultiFlexChoiceForm,
|
||||
TrendFlexModalForm,WorkoutSplitForm,
|
||||
TrendFlexModalForm,WorkoutSplitForm,WorkoutJoinParamForm,
|
||||
)
|
||||
from rowers.models import Workout, User, Rower, WorkoutForm,FavoriteChart
|
||||
from rowers.models import (
|
||||
@@ -3940,6 +3940,7 @@ def oterankings_view(request,theuser=0,
|
||||
paulintercept = 1
|
||||
message = res[4]
|
||||
else:
|
||||
ratio = 1
|
||||
script = ''
|
||||
div = '<p>No ranking pieces found.</p>'
|
||||
paulslope = 1
|
||||
@@ -4033,7 +4034,10 @@ def oterankings_view(request,theuser=0,
|
||||
|
||||
pwr2 = p1[0]/(1+t/p1[2])
|
||||
pwr2 += p1[1]/(1+t/p1[3])
|
||||
pwr2 *= ratio
|
||||
try:
|
||||
pwr2 *= ratio
|
||||
except UnboundLocalError:
|
||||
pass
|
||||
|
||||
if pwr2 <= 0:
|
||||
pwr2 = 50.
|
||||
@@ -4190,6 +4194,209 @@ def workout_setprivate_view(request,id,
|
||||
})
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
# Joining workout
|
||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||
def workouts_join_view(request):
|
||||
promember=0
|
||||
if not request.user.is_anonymous():
|
||||
r = getrower(request.user)
|
||||
result = request.user.is_authenticated() and ispromember(request.user)
|
||||
if result:
|
||||
promember=1
|
||||
|
||||
|
||||
if request.method == 'POST' and 'workouts' in request.POST:
|
||||
form = WorkoutMultipleCompareForm(request.POST)
|
||||
paramform = WorkoutJoinParamForm(request.POST)
|
||||
if form.is_valid() and paramform.is_valid():
|
||||
workout_name = paramform.cleaned_data['workout_name']
|
||||
set_private = paramform.cleaned_data['set_private']
|
||||
|
||||
cd = form.cleaned_data
|
||||
workouts = cd['workouts']
|
||||
ids = [int(w.id) for w in workouts]
|
||||
request.session['ids'] = ids
|
||||
|
||||
|
||||
id,message = dataprep.join_workouts(r,ids,
|
||||
title=workout_name,
|
||||
setprivate=set_private)
|
||||
|
||||
if message:
|
||||
messages.error(request,message)
|
||||
|
||||
url = reverse(workout_edit_view,
|
||||
kwargs = {
|
||||
'id':int(id),
|
||||
})
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
else:
|
||||
return HttpResponse("form is not valid")
|
||||
|
||||
else:
|
||||
url = reverse(workouts_join_select)
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||
def workouts_join_select(request,
|
||||
startdatestring="",
|
||||
enddatestring="",
|
||||
message='',
|
||||
successmessage='',
|
||||
startdate=timezone.now()-datetime.timedelta(days=30),
|
||||
enddate=timezone.now()+datetime.timedelta(days=1),
|
||||
teamid=0):
|
||||
|
||||
try:
|
||||
r = getrower(request.user)
|
||||
except Rower.DoesNotExist:
|
||||
raise Http404("Rower doesn't exist")
|
||||
|
||||
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 'waterboattype' in request.session:
|
||||
waterboattype = request.session['waterboattype']
|
||||
else:
|
||||
waterboattype = ['1x','2x','2-','4x','4-','8+']
|
||||
|
||||
|
||||
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 'daterange' in request.POST:
|
||||
dateform = DateRangeForm(request.POST)
|
||||
if dateform.is_valid():
|
||||
startdate = dateform.cleaned_data['startdate']
|
||||
enddate = dateform.cleaned_data['enddate']
|
||||
startdatestring = startdate.strftime('%Y-%m-%d')
|
||||
enddatestring = enddate.strftime('%Y-%m-%d')
|
||||
request.session['startdate'] = startdatestring
|
||||
request.session['enddate'] = enddatestring
|
||||
else:
|
||||
dateform = DateRangeForm(initial={
|
||||
'startdate':startdate,
|
||||
'enddate':enddate,
|
||||
})
|
||||
|
||||
|
||||
if request.method == 'POST' and 'modality' in request.POST:
|
||||
modalityform = TrendFlexModalForm(request.POST)
|
||||
if modalityform.is_valid():
|
||||
modality = modalityform.cleaned_data['modality']
|
||||
waterboattype = modalityform.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]
|
||||
|
||||
|
||||
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())
|
||||
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
|
||||
|
||||
try:
|
||||
theteam = Team.objects.get(id=teamid)
|
||||
except Team.DoesNotExist:
|
||||
theteam = 0
|
||||
|
||||
if r.rowerplan == 'basic' and theteam==0:
|
||||
raise Http404("Not allowed")
|
||||
|
||||
if theteam and (theteam.viewing == 'allmembers' or theteam.manager == request.user):
|
||||
workouts = Workout.objects.filter(team=theteam,
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate,
|
||||
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
|
||||
elif theteam and theteam.viewing == 'coachonly':
|
||||
workouts = Workout.objects.filter(team=theteam,user=r,
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate,
|
||||
workouttype__in=modalities).order_by("-date","-starttime").exclude(boattype__in=negtypes)
|
||||
|
||||
|
||||
else:
|
||||
theteam = None
|
||||
workouts = Workout.objects.filter(user=r,
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate,
|
||||
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
|
||||
|
||||
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
|
||||
|
||||
if theteam:
|
||||
theid = theteam.id
|
||||
else:
|
||||
theid = 0
|
||||
|
||||
joinparamform = WorkoutJoinParamForm()
|
||||
modalityform = TrendFlexModalForm(initial={
|
||||
'modality':modality,
|
||||
'waterboattype':waterboattype
|
||||
})
|
||||
|
||||
|
||||
messages.info(request,successmessage)
|
||||
messages.error(request,message)
|
||||
|
||||
return render(request, 'workout_join_select.html',
|
||||
{'workouts': workouts,
|
||||
'dateform':dateform,
|
||||
'startdate':startdate,
|
||||
'enddate':enddate,
|
||||
'team':theteam,
|
||||
'form':form,
|
||||
'joinparamform':joinparamform,
|
||||
'modalityform':modalityform,
|
||||
'teams':get_my_teams(request.user),
|
||||
})
|
||||
|
||||
# Team comparison
|
||||
@login_required()
|
||||
def team_comparison_select(request,
|
||||
@@ -5563,7 +5770,7 @@ def workout_fusion_list(request,id=0,message='',successmessage='',
|
||||
})
|
||||
except Rower.DoesNotExist:
|
||||
raise Http404("User has no rower instance")
|
||||
|
||||
|
||||
# Basic 'EDIT' view of workout
|
||||
def workout_view(request,id=0):
|
||||
request.session['referer'] = absolute(request)['PATH']
|
||||
@@ -8657,7 +8864,8 @@ def workout_upload_view(request,
|
||||
optionsform = UploadOptionsForm(request.POST)
|
||||
|
||||
if form.is_valid():
|
||||
f = request.FILES['file']
|
||||
# f = request.FILES['file']
|
||||
f = form.cleaned_data['file']
|
||||
|
||||
res = handle_uploaded_file(f)
|
||||
t = form.cleaned_data['title']
|
||||
|
||||
Reference in New Issue
Block a user