Private
Public Access
1
0

Merge branch 'release/v3.55'

This commit is contained in:
Sander Roosendaal
2017-08-10 15:35:59 +02:00
11 changed files with 542 additions and 136 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ class UserAdmin(UserAdmin):
inlines = (RowerInline,)
class WorkoutAdmin(admin.ModelAdmin):
list_display = ('date','user','name','workouttype')
list_display = ('date','user','name','workouttype','boattype')
class FavoriteChartAdmin(admin.ModelAdmin):
list_display = ('user','xparam','yparam1','yparam2','plottype','workouttype','reststrokes')
+2 -2
View File
@@ -1269,13 +1269,13 @@ def datafusion(id1,id2,columns,offset):
return df
def fix_newtons(id=0):
def fix_newtons(id=0,limit=3000):
# rowdata,row = getrowdata_db(id=id,doclean=False,convertnewtons=False)
rowdata = getsmallrowdata_db(['peakforce'],ids=[id],doclean=False)
try:
#avgforce = rowdata['averageforce']
peakforce = rowdata['peakforce']
if peakforce.mean() > 3000:
if peakforce.mean() > limit:
w = Workout.objects.get(id=id)
print "fixing ",id
rowdata = rdata(w.csvfilename)
+15 -22
View File
@@ -8,7 +8,7 @@ from django.forms.extras.widgets import SelectDateWidget
from django.utils import timezone,translation
from django.forms import ModelForm
import dataprep
import types
import datetime
# login form
@@ -45,18 +45,6 @@ class StrokeDataForm(forms.Form):
# The form used for uploading files
class DocumentsForm(forms.Form):
filetypechoices = (
('csv' , 'Painsled iOS CSV'),
('tcx' , 'TCX'),
('tcxnohr' , 'TCX No HR'),
('rp' , 'RowPro CSV'),
('speedcoach' , 'SpeedCoach GPS CSV'),
('speedcoach2' , 'SpeedCoach GPS 2 CSV'),
('ergdata' , 'ErgData CSV'),
('ergstick' , 'ErgStick CSV'),
('painsleddesktop' , 'Painsled Desktop CSV'),
('zip','Zipped file'),
)
title = forms.CharField(required=False)
file = forms.FileField(required=True,
validators=[validate_file_extension])
@@ -275,15 +263,21 @@ class IntervalUpdateForm(forms.Form):
self.fields['type_%s' % i].widget.attrs['style'] = 'width:156px; height: 22px;'
self.fields['intervald_%s' % i].widget = forms.TimeInput(format='%H:%M:%S.%f')
boattypes = (
('1x', '1x (single)'),
('2x', '2x (double)'),
('2-', '2- (pair)'),
('4x', '4x (quad)'),
('4-', '4- (four)'),
('8+', '8+ (eight)'),
)
boattypes = types.boattypes
workouttypes = types.workouttypes
ww = list(workouttypes)
ww.append(tuple(('all','All')))
workouttypes = tuple(ww)
# form to select modality and boat type for trend flex
class TrendFlexModalForm(forms.Form):
modality = forms.ChoiceField(choices=workouttypes,
label='Workout Type',
initial='all')
waterboattype = forms.MultipleChoiceField(choices=boattypes,
label='Water Boat Type',
initial = ['1x','2x','2-','4x','4-','8+'])
# This form sets options for the summary stats page
class StatsOptionsForm(forms.Form):
@@ -342,7 +336,6 @@ formaxlabelsmultiflex['workoutid'] = 'Workout'
parchoicesmultiflex = list(sorted(formaxlabelsmultiflex.items(), key = lambda x:x[1]))
from utils import palettes
#palettechoices = { key:key for key, value in palettes.iteritems() }
palettechoices = tuple((p,p) for p in palettes.keys())
+6 -2
View File
@@ -1809,7 +1809,11 @@ def interactive_flex_chart2(id=0,promember=0,
rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True,
workstrokesonly=workstrokesonly)
if rowdata.empty:
rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True,
workstrokesonly=False)
workstrokesonly=False
try:
tests = rowdata[yparam2]
except KeyError:
@@ -2250,7 +2254,7 @@ def interactive_flex_chart2(id=0,promember=0,
js_resources = INLINE.render_js()
css_resources = INLINE.render_css()
return [script,div,js_resources,css_resources]
return [script,div,js_resources,css_resources,workstrokesonly]
def interactive_bar_chart(id=0,promember=0):
+29 -57
View File
@@ -22,6 +22,8 @@ import datetime
from django.core.exceptions import ValidationError
from rowers.rows import validate_file_extension
import types
from rowsandall_app.settings import (
TWEET_ACCESS_TOKEN_KEY,
TWEET_ACCESS_TOKEN_SECRET,
@@ -353,53 +355,10 @@ def checkworkoutuser(user,workout):
# Workout
class Workout(models.Model):
workouttypes = (
('water','On-water'),
('rower','Indoor Rower'),
('skierg','Ski Erg'),
('dynamic','Dynamic Indoor Rower'),
('slides','Indoor Rower on Slides'),
('paddle','Paddle Adapter'),
('snow','On-snow'),
('coastal','Coastal'),
('other','Other'),
)
workoutsources = (
('strava','strava'),
('concept2','concept2'),
('sporttracks','sporttracks'),
('runkeeper','runkeeper'),
('mapmyfitness','mapmyfitness'),
('csv','painsled'),
('tcx','tcx'),
('rp','rp'),
('mystery','mystery'),
('tcxnohr','tcx (no HR)'),
('rowperfect3','rowperfect3'),
('ergdata','ergdata'),
('boatcoach','boatcoach'),
('bcmike','boatcoach (develop)'),
('painsleddesktop','painsleddesktop'),
('speedcoach','speedcoach'),
('speedcoach2','speedcoach2'),
('ergstick','ergstick'),
('fit','fit'),
('unknown','unknown'))
boattypes = (
('1x', '1x (single)'),
('2x', '2x (double)'),
('2-', '2- (pair)'),
('4x', '4x (quad)'),
('4-', '4- (four)'),
('8+', '8+ (eight)'),
)
privacychoices = (
('private','Private'),
('visible','Visible'),
)
workouttypes = types.workouttypes
workoutsources = types.workoutsources
boattypes = types.boattypes
privacychoices = types.privacychoices
user = models.ForeignKey(Rower)
team = models.ManyToManyField(Team,blank=True)
@@ -409,7 +368,7 @@ class Workout(models.Model):
workoutsource = models.CharField(choices=workoutsources,max_length=100,
default='unknown')
boattype = models.CharField(choices=boattypes,max_length=50,
default='1x (single)',
default='1x',
verbose_name = 'Boat Type')
starttime = models.TimeField(blank=True,null=True)
startdatetime = models.DateTimeField(blank=True,null=True)
@@ -446,17 +405,30 @@ class Workout(models.Model):
ownerfirst = self.user.user.first_name
ownerlast = self.user.user.last_name
duration = self.duration
boattype = self.boattype
workouttype = self.workouttype
stri = u'{d} {n} {dist}m {duration:%H:%M:%S} {workouttype} {ownerfirst} {ownerlast}'.format(
d = date.strftime('%Y-%m-%d'),
n = name,
dist = distance,
duration = duration,
workouttype = workouttype,
ownerfirst = ownerfirst,
ownerlast = ownerlast,
)
if workouttype != 'water':
stri = u'{d} {n} {dist}m {duration:%H:%M:%S} {workouttype} {ownerfirst} {ownerlast}'.format(
d = date.strftime('%Y-%m-%d'),
n = name,
dist = distance,
duration = duration,
workouttype = workouttype,
ownerfirst = ownerfirst,
ownerlast = ownerlast,
)
else:
stri = u'{d} {n} {dist}m {duration:%H:%M:%S} {workouttype} {boattype} {ownerfirst} {ownerlast}'.format(
d = date.strftime('%Y-%m-%d'),
n = name,
dist = distance,
duration = duration,
workouttype = workouttype,
boattype=boattype,
ownerfirst = ownerfirst,
ownerlast = ownerlast,
)
return stri
+70 -4
View File
@@ -13,6 +13,55 @@
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>
@@ -23,21 +72,38 @@
<h3>{{ team.name }} Team Workouts</h3>
</div>
<div class="grid_12 alpha">
<div class="grid_4 alpha">
<div class="grid_6 alpha">
{% if team %}
<form enctype="multipart/form-data" action="/rowers/team-compare-select/team/{{ team.id }}/" method="post">
{% else %}
<form enctype="multipart/form-data" action="/rowers/team-compare-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>
<div class="grid_2">
<input name='daterange' class="button green" type="submit" value="Submit"> </form>
</form>
{% if team %}
<form enctype="multipart/form-data" action="/rowers/team-compare-select/team/{{ team.id }}/" method="post">
{% else %}
<form enctype="multipart/form-data" action="/rowers/team-compare-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 %}
+82 -14
View File
@@ -12,6 +12,55 @@
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>
@@ -45,23 +94,42 @@
</div>
</div>
<div class="grid_12 alpha">
<div class="grid_4 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 %}
<table>
{{ dateform.as_table }}
</table>
{% csrf_token %}
{% 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>
{{ 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_2">
<input name='daterange' class="button green" type="submit" value="Submit"> </form>
</div>
<div class="grid_5 prefix_1 omega">
<div class="grid_5 prefix_1 omega">
<form id="searchform" action=""
method="get" accept-charset="utf-8">
<div class="grid_3 prefix_1 alpha">
+82 -13
View File
@@ -12,6 +12,55 @@
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>
@@ -45,22 +94,42 @@
</div>
</div>
<div class="grid_12 alpha">
<div class="grid_4 alpha">
<div class="grid_6 alpha">
{% if theuser %}
<form enctype="multipart/form-data" action="/rowers/user-multiflex-select/user/{{ theuser.id }}/" method="post">
{% else %}
<form enctype="multipart/form-data" action="/rowers/user-multiflex-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>
{% else %}
<form enctype="multipart/form-data" action="/rowers/user-multiflex-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-multiflex-select/user/{{ theuser.id }}/" method="post">
{% else %}
<form enctype="multipart/form-data" action="/rowers/user-multiflex-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">
<form id="searchform" action=""
method="get" accept-charset="utf-8">
+47
View File
@@ -0,0 +1,47 @@
workouttypes = (
('water','On-water'),
('rower','Indoor Rower'),
('skierg','Ski Erg'),
('dynamic','Dynamic Indoor Rower'),
('slides','Indoor Rower on Slides'),
('paddle','Paddle Adapter'),
('snow','On-snow'),
('coastal','Coastal'),
('other','Other'),
)
workoutsources = (
('strava','strava'),
('concept2','concept2'),
('sporttracks','sporttracks'),
('runkeeper','runkeeper'),
('mapmyfitness','mapmyfitness'),
('csv','painsled'),
('tcx','tcx'),
('rp','rp'),
('mystery','mystery'),
('tcxnohr','tcx (no HR)'),
('rowperfect3','rowperfect3'),
('ergdata','ergdata'),
('boatcoach','boatcoach'),
('bcmike','boatcoach (develop)'),
('painsleddesktop','painsleddesktop'),
('speedcoach','speedcoach'),
('speedcoach2','speedcoach2'),
('ergstick','ergstick'),
('fit','fit'),
('unknown','unknown'))
boattypes = (
('1x', '1x (single)'),
('2x', '2x (double)'),
('2-', '2- (pair)'),
('4x', '4x (quad)'),
('4-', '4- (four)'),
('8+', '8+ (eight)'),
)
privacychoices = (
('private','Private'),
('visible','Visible'),
)
+9
View File
@@ -5,6 +5,15 @@ import colorsys
lbstoN = 4.44822
def absolute(request):
urls = {
'ABSOLUTE_ROOT': request.build_absolute_uri('/')[:-1].strip("/"),
'ABSOLUTE_ROOT_URL': request.build_absolute_uri('/').strip("/"),
'PATH':request.build_absolute_uri(),
}
return urls
def trcolors(r1,g1,b1,r2,g2,b2):
r1 = r1/255.
r2 = r2/255.
+199 -21
View File
@@ -36,6 +36,7 @@ from rowers.forms import (
RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm,
UpdateStreamForm,WorkoutMultipleCompareForm,ChartParamChoiceForm,
FusionMetricChoiceForm,BoxPlotChoiceForm,MultiFlexChoiceForm,
TrendFlexModalForm,
)
from rowers.models import Workout, User, Rower, WorkoutForm,FavoriteChart
from rowers.models import (
@@ -97,7 +98,7 @@ from scipy.signal import savgol_filter
from django.shortcuts import render_to_response
from Cookie import SimpleCookie
from shutil import copyfile
import types
from rowingdata import rower as rrower
from rowingdata import main as rmain
from rowingdata import rowingdata as rrdata
@@ -273,7 +274,7 @@ def splitstdata(lijst):
from utils import (
geo_distance,serialize_list,deserialize_list,uniqify,
str2bool,range_to_color_hex
str2bool,range_to_color_hex,absolute
)
import datautils
@@ -2106,10 +2107,13 @@ def cum_flex(request,theuser=0,
workouttypes = options['workouttypes']
includereststrokes = options['includereststrokes']
waterboattype = options['waterboattype']
workstrokesonly = not includereststrokes
checktypes = ['water','rower','dynamic','slides','skierg',
'paddle','snow','coastal','other']
waterboattype = ['1x','2x','2-','4x','4-','8+']
if deltadays>0:
startdate = enddate-datetime.timedelta(days=int(deltadays))
@@ -2181,7 +2185,8 @@ def cum_flex(request,theuser=0,
for type in checktypes:
if optionsform.cleaned_data[type]:
workouttypes.append(type)
options = {
'includereststrokes':includereststrokes,
'workouttypes':workouttypes,
@@ -3169,19 +3174,67 @@ def team_comparison_select(request,
except Rower.DoesNotExist:
raise Http404("Rower doesn't exist")
if 'startdate' in request.session:
startdate = iso8601.parse_date(request.session['startdate'])
if request.method == 'POST':
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]
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)
@@ -3207,18 +3260,21 @@ def team_comparison_select(request,
if theteam and (theteam.viewing == 'allmembers' or theteam.manager == request.user):
workouts = Workout.objects.filter(team=theteam,
startdatetime__gte=startdate,
startdatetime__lte=enddate).order_by("-date", "-starttime")
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).order_by("-date","-starttime")
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).order_by("-date", "-starttime")
startdatetime__lte=enddate,
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
query = request.GET.get('q')
if query:
@@ -3239,6 +3295,11 @@ def team_comparison_select(request,
theid = 0
chartform = ChartParamChoiceForm(initial={'teamid':0})
modalityform = TrendFlexModalForm(initial={
'modality':modality,
'waterboattype':waterboattype
})
messages.info(request,successmessage)
messages.error(request,message)
@@ -3251,6 +3312,7 @@ def team_comparison_select(request,
'team':theteam,
'form':form,
'chartform':chartform,
'modalityform':modalityform,
'teams':get_my_teams(request.user),
})
@@ -3374,6 +3436,7 @@ def user_multiflex_select(request,
except:
ploterrorbars = False
if 'startdate' in request.session:
startdate = iso8601.parse_date(request.session['startdate'])
@@ -3383,17 +3446,54 @@ def user_multiflex_select(request,
enddate = iso8601.parse_date(request.session['enddate'])
if request.method == 'POST':
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]
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
startdate = datetime.datetime.combine(startdate,datetime.time())
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
enddate = enddate+datetime.timedelta(days=1)
@@ -3409,9 +3509,15 @@ def user_multiflex_select(request,
startdate = s
negtypes = []
for b in types.boattypes:
if b[0] not in waterboattype:
negtypes.append(b[0])
workouts = Workout.objects.filter(user=r,
startdatetime__gte=startdate,
startdatetime__lte=enddate).order_by("-date", "-starttime")
startdatetime__lte=enddate,
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
query = request.GET.get('q')
if query:
@@ -3432,6 +3538,11 @@ def user_multiflex_select(request,
'includereststrokes':includereststrokes,
})
modalityform = TrendFlexModalForm(initial={
'modality':modality,
'waterboattype':waterboattype
})
messages.info(request,successmessage)
messages.error(request,message)
@@ -3448,6 +3559,7 @@ def user_multiflex_select(request,
'theuser':user,
'form':form,
'chartform':chartform,
'modalityform':modalityform,
'teams':get_my_teams(request.user),
})
@@ -3698,7 +3810,7 @@ def multiflex_view(request,userid=0,
clegendy = df['groupval'].min()+clegendx*(df['groupval'].max()-df['groupval'].min())
else:
clegendy = df.index.min()+clegendx*(df.index.max()-df.index.min())
print clegendy
colorlegend = zip(range(6),clegendy,legcolors)
@@ -3757,17 +3869,53 @@ def user_boxplot_select(request,
enddate = iso8601.parse_date(request.session['enddate'])
if request.method == 'POST':
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]
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
startdate = datetime.datetime.combine(startdate,datetime.time())
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
enddate = enddate+datetime.timedelta(days=1)
@@ -3782,10 +3930,15 @@ def user_boxplot_select(request,
enddate = startdate
startdate = s
negtypes = []
for b in types.boattypes:
if b[0] not in waterboattype:
negtypes.append(b[0])
workouts = Workout.objects.filter(user=r,
startdatetime__gte=startdate,
startdatetime__lte=enddate).order_by("-date", "-starttime")
startdatetime__lte=enddate,
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
query = request.GET.get('q')
if query:
@@ -3801,6 +3954,10 @@ def user_boxplot_select(request,
form.fields["workouts"].queryset = workouts
chartform = BoxPlotChoiceForm()
modalityform = TrendFlexModalForm(initial={
'modality':modality,
'waterboattype':waterboattype
})
messages.info(request,successmessage)
messages.error(request,message)
@@ -3818,6 +3975,7 @@ def user_boxplot_select(request,
'theuser':user,
'form':form,
'chartform':chartform,
'modalityform':modalityform,
'teams':get_my_teams(request.user),
})
@@ -4005,6 +4163,7 @@ def workouts_view(request,message='',successmessage='',
startdate=timezone.now()-datetime.timedelta(days=365),
enddate=timezone.now()+datetime.timedelta(days=1),
teamid=0):
request.session['referer'] = absolute(request)['PATH']
try:
r = getrower(request.user)
except Rower.DoesNotExist:
@@ -4287,6 +4446,8 @@ def workout_fusion_list(request,id=0,message='',successmessage='',
# Basic 'EDIT' view of workout
def workout_view(request,id=0):
request.session['referer'] = absolute(request)['PATH']
try:
# check if valid ID exists (workout exists)
row = Workout.objects.get(id=id)
@@ -5582,7 +5743,7 @@ def workout_flexchart3_view(request,*args,**kwargs):
# create interactive plot
try:
script,div,js_resources,css_resources = interactive_flex_chart2(id,xparam=xparam,yparam1=yparam1,
script,div,js_resources,css_resources,workstrokesonly = interactive_flex_chart2(id,xparam=xparam,yparam1=yparam1,
yparam2=yparam2,
promember=promember,plottype=plottype,
workstrokesonly=workstrokesonly)
@@ -5944,6 +6105,8 @@ def workout_comment_view(request,id=0):
@login_required()
def workout_edit_view(request,id=0,message="",successmessage=""):
request.session[translation.LANGUAGE_SESSION_KEY] = USER_LANGUAGE
request.session['referer'] = absolute(request)['PATH']
try:
# check if valid ID exists (workout exists)
@@ -7576,10 +7739,12 @@ def workout_delete_confirm_view(request, id=0):
if (checkworkoutuser(request.user,row)==False):
raise PermissionDenied("You are not allowed to delete this workout")
else:
url = request.META.get('HTTP_REFERER','/')
return render(request,'workout_delete_confirm.html',
{'id':int(id),
'teams':get_my_teams(request.user),
'workout':row})
'workout':row,
'url':url})
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
@@ -7596,8 +7761,12 @@ def workout_delete_view(request,id=0):
row.delete()
messages.info(request,'Workout deleted')
url = reverse(workouts_view)
try:
url = request.session['referer']
except KeyError:
url = reverse(workouts_view)
return HttpResponseRedirect(url)
except Workout.DoesNotExist:
@@ -7612,10 +7781,16 @@ def graph_delete_confirm_view(request, id=0):
if (checkworkoutuser(request.user,row)==False):
raise PermissionDenied("You are not allowed to delete this workout")
else:
try:
url = request.session['referer']
except KeyError:
url = '/rowers/list-graphs'
request.session['referer'] = url
return render(request,'graphimage_delete_confirm.html',
{'id':int(id),
'teams':get_my_teams(request.user),
'graph':img})
'graph':img,
'url':url})
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
@@ -7633,8 +7808,10 @@ def graph_delete_view(request,id=0):
else:
img.delete()
messages.info(request,'Graph deleted')
url = reverse(workouts_view)
try:
url = request.session['referer']
except KeyError:
url = reverse(graphs_view)
return HttpResponseRedirect(url)
except GraphImage.DoesNotExist:
@@ -7645,6 +7822,7 @@ def graph_delete_view(request,id=0):
# A page with all the recent graphs (searchable on workout name)
@login_required()
def graphs_view(request):
request.session['referer'] = reverse(graphs_view)
try:
r = getrower(request.user)
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")