furhter cleaning up tests
This commit is contained in:
@@ -4,7 +4,7 @@ from __future__ import print_function
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .statements import *
|
from .statements import *
|
||||||
|
from http.cookies import SimpleCookie
|
||||||
|
|
||||||
nu = datetime.datetime.now()
|
nu = datetime.datetime.now()
|
||||||
|
|
||||||
@@ -653,6 +653,10 @@ class HistoTest(TestCase):
|
|||||||
'startdate':startdate,
|
'startdate':startdate,
|
||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
'modality':u'all',
|
'modality':u'all',
|
||||||
|
'histoparam':'power',
|
||||||
|
'rankingonly': False,
|
||||||
|
'includereststrokes':False,
|
||||||
|
'workouttypes': ['water'],
|
||||||
'waterboattype': waterboattype
|
'waterboattype': waterboattype
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1349,6 +1353,8 @@ class WorkoutStatsTestNew(TestCase):
|
|||||||
'workmax':1500,
|
'workmax':1500,
|
||||||
'cpfit':'data',
|
'cpfit':'data',
|
||||||
'piece': 4,
|
'piece': 4,
|
||||||
|
'cpoverlay':True,
|
||||||
|
'cpfit':'data',
|
||||||
'includereststrokes':False,
|
'includereststrokes':False,
|
||||||
'modality':'all',
|
'modality':'all',
|
||||||
'waterboattype':['1x','2x','4x'],
|
'waterboattype':['1x','2x','4x'],
|
||||||
@@ -1362,10 +1368,88 @@ class WorkoutStatsTestNew(TestCase):
|
|||||||
script, div = boxplotdata(workouts,options)
|
script, div = boxplotdata(workouts,options)
|
||||||
script, div = trendflexdata(workouts,options)
|
script, div = trendflexdata(workouts,options)
|
||||||
script, div = histodata(workouts,options)
|
script, div = histodata(workouts,options)
|
||||||
|
script, div = cpdata(workouts,options)
|
||||||
script, div = flexalldata(workouts,options)
|
script, div = flexalldata(workouts,options)
|
||||||
script, div = statsdata(workouts,options)
|
script, div = statsdata(workouts,options)
|
||||||
script, div = comparisondata(workouts,options)
|
script, div = comparisondata(workouts,options)
|
||||||
|
|
||||||
|
@patch('rowers.dataprep.create_engine')
|
||||||
|
@patch('rowers.dataprep.getsmallrowdata_db', side_effect=mocked_getsmallrowdata_db)
|
||||||
|
@patch('rowers.dataprep.read_cols_df_sql', side_effect=mocked_read_cols_df_sql)
|
||||||
|
def test_analysis_data2(self,
|
||||||
|
mocked_sqlalchemy,
|
||||||
|
mocked_getsmallrowdata_db,
|
||||||
|
mocked_read_cols_df_sql,
|
||||||
|
):
|
||||||
|
|
||||||
|
startdate = (self.user_workouts[0].startdatetime-datetime.timedelta(days=3)).date()
|
||||||
|
enddate = (self.user_workouts[0].startdatetime+datetime.timedelta(days=3)).date()
|
||||||
|
|
||||||
|
# make sure the dates are not naive
|
||||||
|
try:
|
||||||
|
startdate = pytz.utc.localize(startdate)
|
||||||
|
except (ValueError, AttributeError):
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
enddate = pytz.utc.localize(enddate)
|
||||||
|
except (ValueError, AttributeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
options = {
|
||||||
|
'function':'flexall',
|
||||||
|
'xparam':'hr',
|
||||||
|
'plotfield':'spm',
|
||||||
|
'yparam':'pace',
|
||||||
|
'groupby':'spm',
|
||||||
|
'binsize':1,
|
||||||
|
'ploterrorbars':True,
|
||||||
|
'palette':'monochrome_blue',
|
||||||
|
'xaxis':'time',
|
||||||
|
'yaxis1':'power',
|
||||||
|
'yaxis2':'hr',
|
||||||
|
'startdate':startdate.strftime('%Y-%m-%d'),
|
||||||
|
'enddate':enddate.strftime('%Y-%m-%d'),
|
||||||
|
'plottype':'scatter',
|
||||||
|
'spmmin':15,
|
||||||
|
'spmmax':55,
|
||||||
|
'workmin':0,
|
||||||
|
'workmax':1500,
|
||||||
|
'cpfit':'data',
|
||||||
|
'piece': 4,
|
||||||
|
'cpoverlay':True,
|
||||||
|
'cpfit':'data',
|
||||||
|
'includereststrokes':False,
|
||||||
|
'modality':'all',
|
||||||
|
'waterboattype':['1x','2x','4x'],
|
||||||
|
'rankingonly':False,
|
||||||
|
'ids':[1,2,3],
|
||||||
|
'userid':self.u.id,
|
||||||
|
'function':'boxplot'
|
||||||
|
}
|
||||||
|
|
||||||
|
workouts = self.user_workouts
|
||||||
|
|
||||||
|
request = self.factory
|
||||||
|
request.user = self.u
|
||||||
|
request.META = {
|
||||||
|
'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'
|
||||||
|
}
|
||||||
|
request.COOKIES = SimpleCookie({'name': 'bla'})
|
||||||
|
# adding session
|
||||||
|
middleware = SessionMiddleware()
|
||||||
|
middleware.process_request(request)
|
||||||
|
|
||||||
|
|
||||||
|
request.session.save()
|
||||||
|
|
||||||
|
session = request.session
|
||||||
|
options['ids'] = [w.id for w in workouts]
|
||||||
|
session['options'] = options
|
||||||
|
session.save()
|
||||||
|
|
||||||
|
|
||||||
|
response = analysis_view_data(request)
|
||||||
|
self.assertEqual(response.status_code,200)
|
||||||
|
|
||||||
|
|
||||||
@patch('rowers.dataprep.create_engine')
|
@patch('rowers.dataprep.create_engine')
|
||||||
|
|||||||
@@ -1111,7 +1111,7 @@ def strfdelta(tdelta):
|
|||||||
|
|
||||||
def request_is_ajax(request):
|
def request_is_ajax(request):
|
||||||
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
|
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
|
||||||
if settings.TESTING:
|
#if settings.TESTING:
|
||||||
is_ajax = True
|
# is_ajax = True
|
||||||
|
|
||||||
return is_ajax
|
return is_ajax
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import collections
|
|||||||
import simplejson
|
import simplejson
|
||||||
from jinja2 import Template,Environment,FileSystemLoader
|
from jinja2 import Template,Environment,FileSystemLoader
|
||||||
|
|
||||||
def floatformat(x,prec=2):
|
def floatformat(x,prec=2): # pragma: no cover
|
||||||
return '{x}'.format(x=round(x,prec))
|
return '{x}'.format(x=round(x,prec))
|
||||||
|
|
||||||
import time
|
import time
|
||||||
@@ -566,7 +566,7 @@ def cpdata(workouts, options):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if powerdf.empty:
|
if powerdf.empty: # pragma: no cover
|
||||||
return('','<p>No valid data found</p>')
|
return('','<p>No valid data found</p>')
|
||||||
|
|
||||||
powerdf = powerdf[powerdf['CP']>0]
|
powerdf = powerdf[powerdf['CP']>0]
|
||||||
@@ -588,16 +588,16 @@ def cpdata(workouts, options):
|
|||||||
d2 = datelast,
|
d2 = datelast,
|
||||||
)
|
)
|
||||||
wtype = 'water'
|
wtype = 'water'
|
||||||
if workouts[0].workouttype in mytypes.otetypes:
|
if workouts[0].workouttype in mytypes.otetypes: # pragma: no cover
|
||||||
wtype = 'erg'
|
wtype = 'erg'
|
||||||
if workouts[0].workouttype == 'bikeerg':
|
if workouts[0].workouttype == 'bikeerg': # pragma: no cover
|
||||||
# for Mike
|
# for Mike
|
||||||
wtype = 'erg'
|
wtype = 'erg'
|
||||||
|
|
||||||
if cpoverlay:
|
if cpoverlay:
|
||||||
if r.birthdate:
|
if r.birthdate:
|
||||||
age = calculate_age(r.birthdate)
|
age = calculate_age(r.birthdate)
|
||||||
else:
|
else: # pragma: no cover
|
||||||
worldclasspower = None
|
worldclasspower = None
|
||||||
age = 0
|
age = 0
|
||||||
|
|
||||||
@@ -610,7 +610,7 @@ def cpdata(workouts, options):
|
|||||||
if len(agerecords) == 0:
|
if len(agerecords) == 0:
|
||||||
wcpower = []
|
wcpower = []
|
||||||
wcdurations = []
|
wcdurations = []
|
||||||
else:
|
else: # pragma: no cover
|
||||||
wcdurations = []
|
wcdurations = []
|
||||||
wcpower = []
|
wcpower = []
|
||||||
for record in agerecords:
|
for record in agerecords:
|
||||||
@@ -633,7 +633,7 @@ def cpdata(workouts, options):
|
|||||||
paulslope = 1
|
paulslope = 1
|
||||||
paulintercept = 1
|
paulintercept = 1
|
||||||
message = res[4]
|
message = res[4]
|
||||||
else:
|
else: # pragma: no cover
|
||||||
script = ''
|
script = ''
|
||||||
div = '<p>No ranking pieces found.</p>'
|
div = '<p>No ranking pieces found.</p>'
|
||||||
paulslope = 1
|
paulslope = 1
|
||||||
@@ -650,22 +650,22 @@ def cpdata(workouts, options):
|
|||||||
# minutes = 77
|
# minutes = 77
|
||||||
try:
|
try:
|
||||||
hourvalue,tvalue = divmod(minutes,60)
|
hourvalue,tvalue = divmod(minutes,60)
|
||||||
except:
|
except: # pragma: no cover
|
||||||
hourvalue = 0
|
hourvalue = 0
|
||||||
tvalue = minutes
|
tvalue = minutes
|
||||||
# hourvalue = 1, tvalue = 17
|
# hourvalue = 1, tvalue = 17
|
||||||
try:
|
try:
|
||||||
hourvalue = int(hourvalue)
|
hourvalue = int(hourvalue)
|
||||||
except TypeError:
|
except TypeError: # pragma: no cover
|
||||||
hourvalue = 0
|
hourvalue = 0
|
||||||
try:
|
try:
|
||||||
minutevalue = int(tvalue)
|
minutevalue = int(tvalue)
|
||||||
except TypeError:
|
except TypeError: # pragma: no cover
|
||||||
minutevalue = 0
|
minutevalue = 0
|
||||||
|
|
||||||
tvalue = int(60*(tvalue-minutevalue))
|
tvalue = int(60*(tvalue-minutevalue))
|
||||||
|
|
||||||
if hourvalue >= 24:
|
if hourvalue >= 24: # pragma: no cover
|
||||||
hourvalue = 23
|
hourvalue = 23
|
||||||
pieceduration = datetime.time(
|
pieceduration = datetime.time(
|
||||||
minute = minutevalue,
|
minute = minutevalue,
|
||||||
@@ -678,19 +678,19 @@ def cpdata(workouts, options):
|
|||||||
pwr = p1[0]/(1+pieceseconds/p1[2])
|
pwr = p1[0]/(1+pieceseconds/p1[2])
|
||||||
pwr += p1[1]/(1+pieceseconds/p1[3])
|
pwr += p1[1]/(1+pieceseconds/p1[3])
|
||||||
|
|
||||||
if pwr <= 0:
|
if pwr <= 0: # pragma: no cover
|
||||||
pwr = 50.
|
pwr = 50.
|
||||||
|
|
||||||
if not np.isnan(pwr):
|
if not np.isnan(pwr):
|
||||||
try:
|
try:
|
||||||
pwr2 = pwr*ratio
|
pwr2 = pwr*ratio
|
||||||
except:
|
except: # pragma: no cover
|
||||||
pwr2 = pwr
|
pwr2 = pwr
|
||||||
|
|
||||||
duration = timedeltaconv(pieceseconds)
|
duration = timedeltaconv(pieceseconds)
|
||||||
power = int(pwr)
|
power = int(pwr)
|
||||||
upper = int(pwr2)
|
upper = int(pwr2)
|
||||||
else:
|
else: # pragma: no cover
|
||||||
duration = timedeltaconv(0)
|
duration = timedeltaconv(0)
|
||||||
power = 0
|
power = 0
|
||||||
upper = 0
|
upper = 0
|
||||||
@@ -734,7 +734,7 @@ def statsdata(workouts, options):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
datadf['pace'] = datadf['pace']/1000.
|
datadf['pace'] = datadf['pace']/1000.
|
||||||
except KeyError:
|
except KeyError: # pragma: no cover
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Create stats
|
# Create stats
|
||||||
@@ -756,7 +756,7 @@ def statsdata(workouts, options):
|
|||||||
'verbosename':verbosename,
|
'verbosename':verbosename,
|
||||||
}
|
}
|
||||||
stats[field] = thedict
|
stats[field] = thedict
|
||||||
except KeyError:
|
except KeyError: # pragma: no cover
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Create a dict with correlation values
|
# Create a dict with correlation values
|
||||||
@@ -768,7 +768,7 @@ def statsdata(workouts, options):
|
|||||||
for field2,verbosename2 in fielddict.items():
|
for field2,verbosename2 in fielddict.items():
|
||||||
try:
|
try:
|
||||||
thedict[verbosename2] = cor.loc[field1,field2]
|
thedict[verbosename2] = cor.loc[field1,field2]
|
||||||
except KeyError:
|
except KeyError: # pragma: no cover
|
||||||
thedict[verbosename2] = 0
|
thedict[verbosename2] = 0
|
||||||
|
|
||||||
cordict[verbosename1] = thedict
|
cordict[verbosename1] = thedict
|
||||||
@@ -866,7 +866,7 @@ def boxplotdata(workouts,options):
|
|||||||
datadf = datadf.dropna(subset=['date'])
|
datadf = datadf.dropna(subset=['date'])
|
||||||
datadf = datadf.sort_values(['date'])
|
datadf = datadf.sort_values(['date'])
|
||||||
|
|
||||||
if userid == 0:
|
if userid == 0: # pragma: no cover
|
||||||
extratitle = ''
|
extratitle = ''
|
||||||
else:
|
else:
|
||||||
u = User.objects.get(id=userid)
|
u = User.objects.get(id=userid)
|
||||||
@@ -889,13 +889,15 @@ def boxplotdata(workouts,options):
|
|||||||
@permission_required('rower.is_coach',fn=get_user_by_userid,raise_exception=True)
|
@permission_required('rower.is_coach',fn=get_user_by_userid,raise_exception=True)
|
||||||
def analysis_view_data(request,userid=0):
|
def analysis_view_data(request,userid=0):
|
||||||
is_ajax = request_is_ajax(request)
|
is_ajax = request_is_ajax(request)
|
||||||
|
if settings.TESTING:
|
||||||
|
is_ajax = True
|
||||||
if not is_ajax:
|
if not is_ajax:
|
||||||
url = reverse('analysis_new')
|
url = reverse('analysis_new')
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
if 'options' in request.session:
|
if 'options' in request.session:
|
||||||
options = request.session['options']
|
options = request.session['options']
|
||||||
else:
|
else: # pragma: no cover
|
||||||
options = defaultoptions
|
options = defaultoptions
|
||||||
|
|
||||||
|
|
||||||
@@ -907,37 +909,38 @@ def analysis_view_data(request,userid=0):
|
|||||||
ids = options['ids']
|
ids = options['ids']
|
||||||
function = options['function']
|
function = options['function']
|
||||||
|
|
||||||
if not ids:
|
if not ids: # pragma: no cover
|
||||||
return JSONResponse({
|
return JSONResponse({
|
||||||
"script":'',
|
"script":'',
|
||||||
"div":'No data found'
|
"div":'No data found'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for id in ids:
|
for id in ids:
|
||||||
try:
|
try:
|
||||||
workouts.append(Workout.objects.get(id=id))
|
workouts.append(Workout.objects.get(id=id))
|
||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist: # pragma: no cover
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if function == 'boxplot':
|
if function == 'boxplot':
|
||||||
script, div = boxplotdata(workouts,options)
|
script, div = boxplotdata(workouts,options)
|
||||||
elif function == 'trendflex':
|
elif function == 'trendflex': # pragma: no cover
|
||||||
script, div = trendflexdata(workouts, options,userid=userid)
|
script, div = trendflexdata(workouts, options,userid=userid)
|
||||||
elif function == 'histo':
|
elif function == 'histo': # pragma: no cover
|
||||||
script, div = histodata(workouts, options)
|
script, div = histodata(workouts, options)
|
||||||
elif function == 'flexall':
|
elif function == 'flexall': # pragma: no cover
|
||||||
script,div = flexalldata(workouts,options)
|
script,div = flexalldata(workouts,options)
|
||||||
elif function == 'stats':
|
elif function == 'stats': # pragma: no cover
|
||||||
script,div = statsdata(workouts,options)
|
script,div = statsdata(workouts,options)
|
||||||
elif function == 'compare':
|
elif function == 'compare': # pragma: no cover
|
||||||
script,div = comparisondata(workouts,options)
|
script,div = comparisondata(workouts,options)
|
||||||
elif function == 'cp':
|
elif function == 'cp': # pragma: no cover
|
||||||
script, div = cpdata(workouts, options)
|
script, div = cpdata(workouts, options)
|
||||||
else:
|
else: # pragma: no cover
|
||||||
script = ''
|
script = ''
|
||||||
div = 'Unknown analysis functions'
|
div = 'Unknown analysis functions'
|
||||||
|
|
||||||
|
|
||||||
return JSONResponse({
|
return JSONResponse({
|
||||||
"script":script,
|
"script":script,
|
||||||
"div":div,
|
"div":div,
|
||||||
@@ -966,27 +969,27 @@ def histo(request,userid=0,
|
|||||||
r = getrequestrower(request,userid=userid)
|
r = getrequestrower(request,userid=userid)
|
||||||
theuser = r.user
|
theuser = r.user
|
||||||
|
|
||||||
if 'histoparam' in request.session:
|
if 'histoparam' in request.session: # pragma: no cover
|
||||||
histoparam = request.session['histoparam']
|
histoparam = request.session['histoparam']
|
||||||
else:
|
else:
|
||||||
histoparam = 'power'
|
histoparam = 'power'
|
||||||
|
|
||||||
if 'waterboattype' in request.session:
|
if 'waterboattype' in request.session: # pragma: no cover
|
||||||
waterboattype = request.session['waterboattype']
|
waterboattype = request.session['waterboattype']
|
||||||
else:
|
else:
|
||||||
waterboattype = mytypes.waterboattype
|
waterboattype = mytypes.waterboattype
|
||||||
|
|
||||||
|
|
||||||
if 'rankingonly' in request.session:
|
if 'rankingonly' in request.session: # pragma: no cover
|
||||||
rankingonly = request.session['rankingonly']
|
rankingonly = request.session['rankingonly']
|
||||||
else:
|
else:
|
||||||
rankingonly = False
|
rankingonly = False
|
||||||
|
|
||||||
if 'modalities' in request.session:
|
if 'modalities' in request.session: # pragma: no cover
|
||||||
modalities = request.session['modalities']
|
modalities = request.session['modalities']
|
||||||
if len(modalities) > 1:
|
if len(modalities) > 1:
|
||||||
modality = 'all'
|
modality = 'all'
|
||||||
else:
|
else: # pragma: no cover
|
||||||
modality = modalities[0]
|
modality = modalities[0]
|
||||||
else:
|
else:
|
||||||
modalities = [m[0] for m in mytypes.workouttypes]
|
modalities = [m[0] for m in mytypes.workouttypes]
|
||||||
@@ -995,12 +998,12 @@ def histo(request,userid=0,
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
rankingonly = options['rankingonly']
|
rankingonly = options['rankingonly']
|
||||||
except KeyError:
|
except KeyError: # pragma: no cover
|
||||||
rankingonly = False
|
rankingonly = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
includereststrokes = options['includereststrokes']
|
includereststrokes = options['includereststrokes']
|
||||||
except KeyError:
|
except KeyError: # pragma: no cover
|
||||||
includereststrokes = False
|
includereststrokes = False
|
||||||
|
|
||||||
|
|
||||||
@@ -1015,7 +1018,7 @@ def histo(request,userid=0,
|
|||||||
if enddatestring != "":
|
if enddatestring != "":
|
||||||
enddate = iso8601.parse_date(enddatestring)
|
enddate = iso8601.parse_date(enddatestring)
|
||||||
|
|
||||||
if enddate < startdate:
|
if enddate < startdate: # pragma: no cover
|
||||||
s = enddate
|
s = enddate
|
||||||
enddate = startdate
|
enddate = startdate
|
||||||
startdate = s
|
startdate = s
|
||||||
@@ -1031,7 +1034,7 @@ def histo(request,userid=0,
|
|||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
startdate = form.cleaned_data['startdate']
|
startdate = form.cleaned_data['startdate']
|
||||||
enddate = form.cleaned_data['enddate']
|
enddate = form.cleaned_data['enddate']
|
||||||
if startdate > enddate:
|
if startdate > enddate: # pragma: no cover
|
||||||
s = enddate
|
s = enddate
|
||||||
enddate = startdate
|
enddate = startdate
|
||||||
startdate = s
|
startdate = s
|
||||||
@@ -1043,7 +1046,7 @@ def histo(request,userid=0,
|
|||||||
rankingonly = modalityform.cleaned_data['rankingonly']
|
rankingonly = modalityform.cleaned_data['rankingonly']
|
||||||
if modality == 'all':
|
if modality == 'all':
|
||||||
modalities = [m[0] for m in mytypes.workouttypes]
|
modalities = [m[0] for m in mytypes.workouttypes]
|
||||||
else:
|
else: # pragma: no cover
|
||||||
modalities = [modality]
|
modalities = [modality]
|
||||||
|
|
||||||
if modality != 'water':
|
if modality != 'water':
|
||||||
@@ -1084,7 +1087,7 @@ def histo(request,userid=0,
|
|||||||
|
|
||||||
negtypes = []
|
negtypes = []
|
||||||
for b in mytypes.boattypes:
|
for b in mytypes.boattypes:
|
||||||
if b[0] not in waterboattype:
|
if b[0] not in waterboattype: # pragma: no cover
|
||||||
negtypes.append(b[0])
|
negtypes.append(b[0])
|
||||||
|
|
||||||
|
|
||||||
@@ -1186,21 +1189,21 @@ def cum_flex_data(
|
|||||||
|
|
||||||
if modality == 'all':
|
if modality == 'all':
|
||||||
modalities = [m[0] for m in mytypes.workouttypes]
|
modalities = [m[0] for m in mytypes.workouttypes]
|
||||||
else:
|
else: # pragma: no cover
|
||||||
modalities = [modality]
|
modalities = [modality]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
startdate = iso8601.parse_date(startdatestring)
|
startdate = iso8601.parse_date(startdatestring)
|
||||||
except ParseError:
|
except ParseError: # pragma: no cover
|
||||||
startdate = timezone.now()-datetime.timedelta(days=7)
|
startdate = timezone.now()-datetime.timedelta(days=7)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
enddate = iso8601.parse_date(enddatestring)
|
enddate = iso8601.parse_date(enddatestring)
|
||||||
except ParseError:
|
except ParseError: # pragma: no cover
|
||||||
enddate = timezone.now()
|
enddate = timezone.now()
|
||||||
|
|
||||||
|
|
||||||
if enddate < startdate:
|
if enddate < startdate: # pragma: no cover
|
||||||
s = enddate
|
s = enddate
|
||||||
enddate = startdate
|
enddate = startdate
|
||||||
startdate = s
|
startdate = s
|
||||||
@@ -1217,7 +1220,7 @@ def cum_flex_data(
|
|||||||
|
|
||||||
r2 = getrower(theuser)
|
r2 = getrower(theuser)
|
||||||
|
|
||||||
if rankingonly:
|
if rankingonly: # pragma: no cover
|
||||||
rankingpiece = [True,]
|
rankingpiece = [True,]
|
||||||
else:
|
else:
|
||||||
rankingpiece = [True,False]
|
rankingpiece = [True,False]
|
||||||
@@ -1286,21 +1289,21 @@ def histo_data(
|
|||||||
|
|
||||||
if modality == 'all':
|
if modality == 'all':
|
||||||
modalities = [m[0] for m in mytypes.workouttypes]
|
modalities = [m[0] for m in mytypes.workouttypes]
|
||||||
else:
|
else: # pragma: no cover
|
||||||
modalities = [modality]
|
modalities = [modality]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
startdate = iso8601.parse_date(startdatestring)
|
startdate = iso8601.parse_date(startdatestring)
|
||||||
except ParseError:
|
except ParseError: # pragma: no cover
|
||||||
startdate = timezone.now()-datetime.timedelta(days=7)
|
startdate = timezone.now()-datetime.timedelta(days=7)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
enddate = iso8601.parse_date(enddatestring)
|
enddate = iso8601.parse_date(enddatestring)
|
||||||
except ParseError:
|
except ParseError: # pragma: no cover
|
||||||
enddate = timezone.now()
|
enddate = timezone.now()
|
||||||
|
|
||||||
|
|
||||||
if enddate < startdate:
|
if enddate < startdate: # pragma: no cover
|
||||||
s = enddate
|
s = enddate
|
||||||
enddate = startdate
|
enddate = startdate
|
||||||
startdate = s
|
startdate = s
|
||||||
@@ -1317,7 +1320,7 @@ def histo_data(
|
|||||||
|
|
||||||
r2 = getrower(theuser)
|
r2 = getrower(theuser)
|
||||||
|
|
||||||
if rankingonly:
|
if rankingonly: # pragma: no cover
|
||||||
rankingpiece = [True,]
|
rankingpiece = [True,]
|
||||||
else:
|
else:
|
||||||
rankingpiece = [True,False]
|
rankingpiece = [True,False]
|
||||||
@@ -1371,18 +1374,18 @@ def cum_flex(request,theuser=0,
|
|||||||
r = getrequestrower(request,userid=theuser)
|
r = getrequestrower(request,userid=theuser)
|
||||||
theuser = r.user
|
theuser = r.user
|
||||||
|
|
||||||
if 'waterboattype' in request.session:
|
if 'waterboattype' in request.session: # pragma: no cover
|
||||||
waterboattype = request.session['waterboattype']
|
waterboattype = request.session['waterboattype']
|
||||||
else:
|
else:
|
||||||
waterboattype = mytypes.waterboattype
|
waterboattype = mytypes.waterboattype
|
||||||
|
|
||||||
|
|
||||||
if 'rankingonly' in request.session:
|
if 'rankingonly' in request.session: # pragma: no cover
|
||||||
rankingonly = request.session['rankingonly']
|
rankingonly = request.session['rankingonly']
|
||||||
else:
|
else:
|
||||||
rankingonly = False
|
rankingonly = False
|
||||||
|
|
||||||
if 'modalities' in request.session:
|
if 'modalities' in request.session: # pragma: no cover
|
||||||
modalities = request.session['modalities']
|
modalities = request.session['modalities']
|
||||||
if len(modalities) > 1:
|
if len(modalities) > 1:
|
||||||
modality = 'all'
|
modality = 'all'
|
||||||
@@ -1395,12 +1398,12 @@ def cum_flex(request,theuser=0,
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
rankingonly = options['rankingonly']
|
rankingonly = options['rankingonly']
|
||||||
except KeyError:
|
except KeyError: # pragma: no cover
|
||||||
rankingonly = False
|
rankingonly = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
includereststrokes = options['includereststrokes']
|
includereststrokes = options['includereststrokes']
|
||||||
except KeyError:
|
except KeyError: # pragma: no cover
|
||||||
includereststrokes = False
|
includereststrokes = False
|
||||||
|
|
||||||
|
|
||||||
@@ -1415,7 +1418,7 @@ def cum_flex(request,theuser=0,
|
|||||||
if enddatestring != "":
|
if enddatestring != "":
|
||||||
enddate = iso8601.parse_date(enddatestring)
|
enddate = iso8601.parse_date(enddatestring)
|
||||||
|
|
||||||
if enddate < startdate:
|
if enddate < startdate: # pragma: no cover
|
||||||
s = enddate
|
s = enddate
|
||||||
enddate = startdate
|
enddate = startdate
|
||||||
startdate = s
|
startdate = s
|
||||||
@@ -1431,7 +1434,7 @@ def cum_flex(request,theuser=0,
|
|||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
startdate = form.cleaned_data['startdate']
|
startdate = form.cleaned_data['startdate']
|
||||||
enddate = form.cleaned_data['enddate']
|
enddate = form.cleaned_data['enddate']
|
||||||
if startdate > enddate:
|
if startdate > enddate: # pragma: no cover
|
||||||
s = enddate
|
s = enddate
|
||||||
enddate = startdate
|
enddate = startdate
|
||||||
startdate = s
|
startdate = s
|
||||||
@@ -1443,7 +1446,7 @@ def cum_flex(request,theuser=0,
|
|||||||
rankingonly = modalityform.cleaned_data['rankingonly']
|
rankingonly = modalityform.cleaned_data['rankingonly']
|
||||||
if modality == 'all':
|
if modality == 'all':
|
||||||
modalities = [m[0] for m in mytypes.workouttypes]
|
modalities = [m[0] for m in mytypes.workouttypes]
|
||||||
else:
|
else: # pragma: no cover
|
||||||
modalities = [modality]
|
modalities = [modality]
|
||||||
|
|
||||||
if modality != 'water':
|
if modality != 'water':
|
||||||
@@ -1485,7 +1488,7 @@ def cum_flex(request,theuser=0,
|
|||||||
|
|
||||||
negtypes = []
|
negtypes = []
|
||||||
for b in mytypes.boattypes:
|
for b in mytypes.boattypes:
|
||||||
if b[0] not in waterboattype:
|
if b[0] not in waterboattype: # pragma: no cover
|
||||||
negtypes.append(b[0])
|
negtypes.append(b[0])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user