modality and boat type selection working on multiflex
This commit is contained in:
@@ -98,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
|
||||
@@ -3375,6 +3375,7 @@ def user_multiflex_select(request,
|
||||
except:
|
||||
ploterrorbars = False
|
||||
|
||||
|
||||
|
||||
if 'startdate' in request.session:
|
||||
startdate = iso8601.parse_date(request.session['startdate'])
|
||||
@@ -3384,17 +3385,55 @@ 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
|
||||
print 'nootje',enddatestring,request.session['enddate']
|
||||
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)
|
||||
@@ -3410,9 +3449,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:
|
||||
@@ -3433,7 +3478,10 @@ def user_multiflex_select(request,
|
||||
'includereststrokes':includereststrokes,
|
||||
})
|
||||
|
||||
modalityform = TrendFlexModalForm()
|
||||
modalityform = TrendFlexModalForm(initial={
|
||||
'modality':modality,
|
||||
'waterboattype':waterboattype
|
||||
})
|
||||
|
||||
messages.info(request,successmessage)
|
||||
messages.error(request,message)
|
||||
@@ -3702,7 +3750,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)
|
||||
|
||||
Reference in New Issue
Block a user