force curve with workstrokesonly
This commit is contained in:
@@ -1,5 +1,176 @@
|
||||
from statements import *
|
||||
|
||||
# Histogram for a date/time range
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
redirect_field_name=None)
|
||||
def histo(request,theuser=0,
|
||||
startdate=timezone.now()-datetime.timedelta(days=365),
|
||||
enddate=timezone.now(),
|
||||
deltadays=-1,
|
||||
enddatestring=timezone.now().strftime("%Y-%m-%d"),
|
||||
startdatestring=(timezone.now()-datetime.timedelta(days=30)).strftime("%Y-%m-%d"),
|
||||
options={
|
||||
'includereststrokes':False,
|
||||
'workouttypes':[i[0] for i in mytypes.workouttypes],
|
||||
'waterboattype':mytypes.waterboattype,
|
||||
'rankingonly': False,
|
||||
}):
|
||||
|
||||
r = getrequestrower(request,userid=theuser)
|
||||
theuser = r.user
|
||||
|
||||
if 'waterboattype' in request.session:
|
||||
waterboattype = request.session['waterboattype']
|
||||
else:
|
||||
waterboattype = mytypes.waterboattype
|
||||
|
||||
|
||||
if 'rankingonly' in request.session:
|
||||
rankingonly = request.session['rankingonly']
|
||||
else:
|
||||
rankingonly = False
|
||||
|
||||
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 mytypes.workouttypes]
|
||||
modality = 'all'
|
||||
|
||||
|
||||
try:
|
||||
rankingonly = options['rankingonly']
|
||||
except KeyError:
|
||||
rankingonly = False
|
||||
|
||||
try:
|
||||
includereststrokes = options['includereststrokes']
|
||||
except KeyError:
|
||||
includereststrokes = False
|
||||
|
||||
|
||||
workstrokesonly = not includereststrokes
|
||||
|
||||
waterboattype = mytypes.waterboattype
|
||||
|
||||
|
||||
if startdatestring != "":
|
||||
startdate = iso8601.parse_date(startdatestring)
|
||||
|
||||
if enddatestring != "":
|
||||
enddate = iso8601.parse_date(enddatestring)
|
||||
|
||||
if enddate < startdate:
|
||||
s = enddate
|
||||
enddate = startdate
|
||||
startdate = s
|
||||
|
||||
|
||||
# get all indoor rows of in date range
|
||||
|
||||
# process form
|
||||
if request.method == 'POST':
|
||||
form = DateRangeForm(request.POST)
|
||||
modalityform = TrendFlexModalForm(request.POST)
|
||||
if form.is_valid():
|
||||
startdate = form.cleaned_data['startdate']
|
||||
enddate = form.cleaned_data['enddate']
|
||||
if startdate > enddate:
|
||||
s = enddate
|
||||
enddate = startdate
|
||||
startdate = s
|
||||
startdatestring = startdate.strftime('%Y-%m-%d')
|
||||
enddatestring = enddate.strftime('%Y-%m-%d')
|
||||
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 mytypes.workouttypes]
|
||||
else:
|
||||
modalities = [modality]
|
||||
|
||||
if modality != 'water':
|
||||
waterboattype = [b[0] for b in mytypes.boattypes]
|
||||
|
||||
|
||||
request.session['modalities'] = modalities
|
||||
request.session['waterboattype'] = waterboattype
|
||||
request.session['rankingonly'] = rankingonly
|
||||
form = DateRangeForm(initial={
|
||||
'startdate': startdate,
|
||||
'enddate': enddate,
|
||||
})
|
||||
else:
|
||||
form = DateRangeForm(initial={
|
||||
'startdate': startdate,
|
||||
'enddate': enddate,
|
||||
})
|
||||
includereststrokes = False
|
||||
|
||||
workstrokesonly = not includereststrokes
|
||||
modalityform = TrendFlexModalForm(
|
||||
initial={
|
||||
'modality':modality,
|
||||
'waterboattype':waterboattype,
|
||||
'rankingonly':rankingonly,
|
||||
}
|
||||
)
|
||||
|
||||
negtypes = []
|
||||
for b in mytypes.boattypes:
|
||||
if b[0] not in waterboattype:
|
||||
negtypes.append(b[0])
|
||||
|
||||
|
||||
|
||||
script = ''
|
||||
div = get_call()
|
||||
js_resources = ''
|
||||
css_resources = ''
|
||||
|
||||
|
||||
|
||||
|
||||
options = {
|
||||
'modality': modality,
|
||||
'theuser': theuser.id,
|
||||
'waterboattype':waterboattype,
|
||||
'startdatestring':startdatestring,
|
||||
'enddatestring':enddatestring,
|
||||
'rankingonly':rankingonly,
|
||||
'includereststrokes':includereststrokes,
|
||||
}
|
||||
|
||||
request.session['options'] = options
|
||||
|
||||
promember=0
|
||||
mayedit=0
|
||||
if not request.user.is_anonymous():
|
||||
result = request.user.is_authenticated() and ispromember(request.user)
|
||||
if result:
|
||||
promember = 1
|
||||
|
||||
|
||||
request.session['options'] = options
|
||||
|
||||
return render(request, 'histo.html',
|
||||
{'interactiveplot':script,
|
||||
'the_div':div,
|
||||
'id':theuser,
|
||||
'active':'nav-analysis',
|
||||
'theuser':theuser,
|
||||
'rower':r,
|
||||
'startdate':startdate,
|
||||
'enddate':enddate,
|
||||
'form':form,
|
||||
'optionsform':modalityform,
|
||||
'teams':get_my_teams(request.user),
|
||||
})
|
||||
|
||||
# The Flex plot for a large selection of workouts
|
||||
@login_required()
|
||||
|
||||
Reference in New Issue
Block a user