Private
Public Access
1
0

added ranking only options

This commit is contained in:
Sander Roosendaal
2018-06-08 13:55:38 +02:00
parent 85ebdd3ba0
commit a6a564559c
2 changed files with 111 additions and 45 deletions

View File

@@ -522,30 +522,30 @@ class TrendFlexModalForm(forms.Form):
waterboattype = forms.MultipleChoiceField(choices=boattypes,
label='Water Boat Type',
initial = types.waterboattype)
rankingonly = forms.BooleanField(initial=False,
label='Only Ranking Pieces',
required=True)
# This form sets options for the summary stats page
class StatsOptionsForm(forms.Form):
includereststrokes = forms.BooleanField(initial=False,label='Include Rest Strokes',required=False)
rankingonly = forms.BooleanField(initial=False,
label='Only Ranking Pieces',required=True)
water = forms.BooleanField(initial=False,required=False)
waterboattype = forms.MultipleChoiceField(choices=boattypes,
label='Water Boat Type',
widget=forms.CheckboxSelectMultiple(),
initial = types.waterboattype)
def __init__(self, *args, **kwargs):
super(StatsOptionsForm, self).__init__(*args,**kwargs)
for type in types.checktypes:
self.fields[type] = forms.BooleanField(initial=True,required=False)
# rower = forms.BooleanField(initial=True,required=False)
# dynamic = forms.BooleanField(initial=True,required=False)
# slides = forms.BooleanField(initial=True,required=False)
# skierg = forms.BooleanField(initial=False,required=False)
# paddle = forms.BooleanField(initial=False,required=False)
# snow = forms.BooleanField(initial=False,required=False)
# coastal = forms.BooleanField(initial=False,required=False)
# other = forms.BooleanField(initial=False,required=False)
class CourseSelectForm(forms.Form):
course = forms.ModelChoiceField(queryset=GeoCourse.objects.all())

View File

@@ -2969,6 +2969,7 @@ def cum_flex_data(
request,
options={
'includereststrokes':False,
'rankingonly':False,
'workouttypes':[i[0] for i in types.workouttypes],
'waterboattype':types.waterboattype,
'theuser':0,
@@ -2984,6 +2985,7 @@ def cum_flex_data(
options = request.session['options']
workouttypes = options['workouttypes']
rankingonly = options['rankingonly']
includereststrokes = options['includereststrokes']
waterboattype = options['waterboattype']
workstrokesonly = not includereststrokes
@@ -3026,23 +3028,31 @@ def cum_flex_data(
promember=1
r2 = getrower(theuser)
if rankingonly:
rankingpiece = [True,]
else:
rankingpiece = [True,False]
allworkouts = Workout.objects.filter(user=r2,
workouttype__in=workouttypes,
boattype__in=waterboattype,
startdatetime__gte=startdate,
startdatetime__lte=enddate)
startdatetime__lte=enddate,
rankingpiece__in=rankingpiece)
if allworkouts:
res = interactive_cum_flex_chart2(allworkouts,xparam=xparam,
yparam1=yparam1,
yparam2=yparam2,
promember=promember,
workstrokesonly=workstrokesonly)
workstrokesonly=workstrokesonly,
rankingpiece__in=rankingpiece)
script = res[0]
div = res[1]
else:
script = ''
div = '<p>No erg pieces uploaded for this date range.</p>'
div = '<p>No pieces uploaded for this date range.</p>'
scripta = script.split('\n')[2:-1]
script = ''.join(scripta)
@@ -3070,7 +3080,8 @@ def cum_flex(request,theuser=0,
options={
'includereststrokes':False,
'workouttypes':[i[0] for i in types.workouttypes],
'waterboattype':types.waterboattype
'waterboattype':types.waterboattype,
'rankingonly':False,
}):
if 'options' in request.session:
@@ -3086,6 +3097,11 @@ def cum_flex(request,theuser=0,
except KeyError:
includereststrokes = False
try:
rankingonly = options['rankingonly']
except KeyError:
rankingonly = False
try:
waterboattype = options['waterboattype']
except KeyError:
@@ -3093,10 +3109,6 @@ def cum_flex(request,theuser=0,
workstrokesonly = not includereststrokes
# checktypes = ['water','rower','dynamic','slides','skierg',
# 'paddle','snow','coastal','other']
if deltadays>0:
startdate = enddate-datetime.timedelta(days=int(deltadays))
@@ -3130,8 +3142,6 @@ def cum_flex(request,theuser=0,
if result:
promember=1
#if not promember:
#return HttpResponseRedirect("/rowers/about/")
# get all indoor rows of in date range
@@ -3170,6 +3180,7 @@ def cum_flex(request,theuser=0,
optionsform = StatsOptionsForm(request.POST)
if optionsform.is_valid():
includereststrokes = optionsform.cleaned_data['includereststrokes']
rankingonly = optionsform.cleaned_data['rankingonly']
workstrokesonly = not includereststrokes
waterboattype = optionsform.cleaned_data['waterboattype']
workouttypes = []
@@ -3182,6 +3193,7 @@ def cum_flex(request,theuser=0,
'includereststrokes':includereststrokes,
'workouttypes':workouttypes,
'waterboattype':waterboattype,
'rankingonly':rankingonly,
}
request.session['options'] = options
form = DateRangeForm(initial={
@@ -3216,7 +3228,7 @@ def cum_flex(request,theuser=0,
# set options form correctly
initial = {}
initial['includereststrokes'] = includereststrokes
initial['rankingonly'] = rankingonly
initial['waterboattype'] = waterboattype
for wtype in types.checktypes:
@@ -3235,6 +3247,7 @@ def cum_flex(request,theuser=0,
options['includereststrokes'] = includereststrokes
options['rankingonly'] = includereststrokes
options['workouttypes'] =workouttypes
options['waterboattype'] =waterboattype
options['theuser'] =theuser
@@ -5730,6 +5743,11 @@ def user_multiflex_select(request,
else:
waterboattype = types.waterboattype
if 'rankingonly' in request.session:
rankingonly = request.session['rankingonly']
else:
rankingonly = False
if 'modalities' in request.session:
modalities = request.session['modalities']
@@ -5761,6 +5779,7 @@ def user_multiflex_select(request,
if modalityform.is_valid():
modality = modalityform.cleaned_data['modality']
waterboattype = modalityform.cleaned_data['waterboattype']
rankingonly = modalityform.cleaned_data['rankingonly']
if modality == 'all':
modalities = [m[0] for m in types.workouttypes]
else:
@@ -5772,7 +5791,7 @@ def user_multiflex_select(request,
request.session['modalities'] = modalities
request.session['waterboattype'] = waterboattype
request.session['rankingonly'] = rankingonly
startdate = datetime.datetime.combine(startdate,datetime.time())
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
@@ -5793,11 +5812,23 @@ def user_multiflex_select(request,
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,
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
if rankingonly:
rankingpiece = [True]
else:
rankingpiece = [True,False]
workouts = Workout.objects.filter(
user=r,
startdatetime__gte=startdate,
startdatetime__lte=enddate,
workouttype__in=modalities,
rankingpiece__in=rankingpiece
).order_by(
"-date", "-starttime"
).exclude(
boattype__in=negtypes
)
query = request.GET.get('q')
if query:
@@ -6222,7 +6253,8 @@ def user_boxplot_select(request,
options={
'includereststrokes':False,
'workouttypes':['rower','dynamic','slides'],
'waterboattype':types.waterboattype
'waterboattype':types.waterboattype,
'rankingonly':False,
},
userid=0):
@@ -6238,6 +6270,11 @@ def user_boxplot_select(request,
except KeyError:
workouttypes = ['rower','dynamic','slides']
try:
rankingonly = options['rankingonly']
except KeyError:
rankingonly = False
try:
includereststrokes = options['includereststrokes']
except KeyError:
@@ -6246,8 +6283,6 @@ def user_boxplot_select(request,
workstrokesonly = not includereststrokes
# checktypes = ['water','rower','dynamic','slides','skierg',
# 'paddle','snow','other','coastal']
waterboattype = types.waterboattype
if 'startdate' in request.session:
@@ -6295,6 +6330,7 @@ def user_boxplot_select(request,
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)
@@ -6302,6 +6338,7 @@ def user_boxplot_select(request,
options = {
'workouttypes':workouttypes,
'waterboattype':waterboattype,
'rankingonly':rankingonly,
}
request.session['options'] = options
@@ -6325,20 +6362,31 @@ 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
if 'water' in workouttypes:
waterinclude = True
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='water',
workouttype__in=types.otwtypes,
rankingpiece__in=rankingpiece,
).exclude(boattype__in=negtypes)
workouttypes = [w for w in workouttypes if w != 'water']
workouttypes = [w for w in workouttypes if w not in types.otwtypes]
workoutse = Workout.objects.filter(user=r,
startdatetime__gte=startdate,
startdatetime__lte=enddate,
workouttype__in=workouttypes)
workouttype__in=workouttypes,
rankingpiece__in=rankingpiece)
if waterinclude:
workouts = workoutse | workoutsw
@@ -6347,9 +6395,8 @@ def user_boxplot_select(request,
workouts = workoutse.order_by("-date","-starttime")
if waterinclude:
workouttypes.append('water')
for ttype in types.otwtypes:
workouttypes.append(ttype)
query = request.GET.get('q')
if query:
@@ -7710,7 +7757,8 @@ def cumstats(request,theuser=0,
options={
'includereststrokes':False,
'workouttypes':['rower','dynamic','slides'],
'waterboattype':types.waterboattype
'waterboattype':types.waterboattype,
'rankingonly':False,
}):
if 'options' in request.session:
@@ -7728,10 +7776,13 @@ def cumstats(request,theuser=0,
includereststrokes = False
try:
rankingonly = options['rankingonly']
except KeyError:
rankingonly = False
workstrokesonly = not includereststrokes
# checktypes = ['water','rower','dynamic','slides','skierg',
# 'paddle','snow','other','coastal']
waterboattype = types.waterboattype
if deltadays>0:
@@ -7807,6 +7858,7 @@ def cumstats(request,theuser=0,
includereststrokes = optionsform.cleaned_data['includereststrokes']
workstrokesonly = not includereststrokes
workouttypes = []
rankingonly = optionsform.cleaned_data['rankingonly']
waterboattype = optionsform.cleaned_data['waterboattype']
for type in types.checktypes:
if optionsform.cleaned_data[type]:
@@ -7816,6 +7868,7 @@ def cumstats(request,theuser=0,
'includereststrokes':includereststrokes,
'workouttypes':workouttypes,
'waterboattype':waterboattype,
'rankingonly':rankingonly,
}
request.session['options'] = options
form = DateRangeForm()
@@ -7833,21 +7886,32 @@ def cumstats(request,theuser=0,
try:
r2 = getrower(theuser)
if rankingonly:
rankingpiece = [True]
else:
rankingpiece = [True,False]
waterinclude = False
if 'water' in workouttypes:
waterinclude = True
for ttype in types.otwtypes:
if ttype in workouttypes:
waterinclude = True
if waterinclude:
workoutsw = Workout.objects.filter(user=r2,
startdatetime__gte=startdate,
startdatetime__lte=enddate,
workouttype='water',
boattype__in='waterboattype'
boattype__in='waterboattype',
rankingpiece__in=rankingpiece,
)
workouttypes = [w for w in workouttypes if w != 'water']
workoutse = Workout.objects.filter(user=r2,
startdatetime__gte=startdate,
startdatetime__lte=enddate,
workouttype__in=workouttypes)
workouttype__in=workouttypes,
rankingpiece__in=rankingpiece)
if waterinclude:
allergworkouts = workoutse | workoutsw
@@ -7856,7 +7920,9 @@ def cumstats(request,theuser=0,
allergworkouts = workoutse.order_by("-date","-starttime")
if waterinclude:
workouttypes.append('water')
for ttype in types.otwtypes:
workouttypes.append(ttype)
except Rower.DoesNotExist: