f
This commit is contained in:
@@ -1900,9 +1900,6 @@ def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
|||||||
df['date'] = df.index.values
|
df['date'] = df.index.values
|
||||||
|
|
||||||
|
|
||||||
#for row in df.iterrows():
|
|
||||||
# print(row)
|
|
||||||
|
|
||||||
source = ColumnDataSource(
|
source = ColumnDataSource(
|
||||||
data = dict(
|
data = dict(
|
||||||
testpower = df['testpower'],
|
testpower = df['testpower'],
|
||||||
@@ -3141,7 +3138,8 @@ def interactive_agegroupcpchart(age,normalized=False):
|
|||||||
mlduration.append(duration)
|
mlduration.append(duration)
|
||||||
mlpower.append(worldclasspower)
|
mlpower.append(worldclasspower)
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
pass
|
mlduration.append(duration)
|
||||||
|
mlpower.append(np.nan)
|
||||||
for duration in durations:
|
for duration in durations:
|
||||||
worldclasspower = c2stuff.getagegrouprecord(
|
worldclasspower = c2stuff.getagegrouprecord(
|
||||||
age,
|
age,
|
||||||
@@ -3155,7 +3153,8 @@ def interactive_agegroupcpchart(age,normalized=False):
|
|||||||
mlduration.append(60.*duration)
|
mlduration.append(60.*duration)
|
||||||
mlpower.append(worldclasspower)
|
mlpower.append(worldclasspower)
|
||||||
except ValueError: # pragma: no cover
|
except ValueError: # pragma: no cover
|
||||||
pass
|
mlduration.append(60.*duration)
|
||||||
|
mlpower.append(np.nan)
|
||||||
|
|
||||||
|
|
||||||
mhduration = []
|
mhduration = []
|
||||||
@@ -3174,7 +3173,8 @@ def interactive_agegroupcpchart(age,normalized=False):
|
|||||||
mhduration.append(duration)
|
mhduration.append(duration)
|
||||||
mhpower.append(worldclasspower)
|
mhpower.append(worldclasspower)
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
pass
|
mhduration.append(duration)
|
||||||
|
mhpower.append(np.nan)
|
||||||
for duration in durations:
|
for duration in durations:
|
||||||
worldclasspower = c2stuff.getagegrouprecord(
|
worldclasspower = c2stuff.getagegrouprecord(
|
||||||
age,
|
age,
|
||||||
@@ -3188,7 +3188,8 @@ def interactive_agegroupcpchart(age,normalized=False):
|
|||||||
mhduration.append(60.*duration)
|
mhduration.append(60.*duration)
|
||||||
mhpower.append(worldclasspower)
|
mhpower.append(worldclasspower)
|
||||||
except ValueError: # pragma: no cover
|
except ValueError: # pragma: no cover
|
||||||
pass
|
mhduration.append(60.*duration)
|
||||||
|
mhpower.append(np.nan)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -3247,23 +3248,43 @@ def interactive_agegroupcpchart(age,normalized=False):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
source = ColumnDataSource(
|
sourcemh = ColumnDataSource(
|
||||||
|
data = dict(
|
||||||
|
mhduration = mhduration,
|
||||||
|
mhpower = mhpower,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
sourcefl = ColumnDataSource(
|
||||||
|
data = dict(
|
||||||
|
flduration = flduration,
|
||||||
|
flpower = flpower,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
sourcefh = ColumnDataSource(
|
||||||
|
data = dict(
|
||||||
|
fhduration = fhduration,
|
||||||
|
fhpower = fhpower,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
sourceml = ColumnDataSource(
|
||||||
|
data = dict(
|
||||||
|
mlduration = mlduration,
|
||||||
|
mlpower = mlpower,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
sourcefit = ColumnDataSource(
|
||||||
data = dict(
|
data = dict(
|
||||||
duration = fitt,
|
duration = fitt,
|
||||||
fitpowerfh = fitpowerfh,
|
fitpowerfh = fitpowerfh,
|
||||||
fitpowerfl = fitpowerfl,
|
fitpowerfl = fitpowerfl,
|
||||||
fitpowerml = fitpowerml,
|
fitpowerml = fitpowerml,
|
||||||
fitpowermh = fitpowermh,
|
fitpowermh = fitpowermh,
|
||||||
flduration = flduration,
|
|
||||||
flpower = flpower,
|
|
||||||
fhduration = fhduration,
|
|
||||||
fhpower = fhpower,
|
|
||||||
mlduration = mlduration,
|
|
||||||
mlpower = mlpower,
|
|
||||||
mhduration = mhduration,
|
|
||||||
mhpower = mhpower,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
x_axis_type = 'log'
|
x_axis_type = 'log'
|
||||||
y_axis_type = 'linear'
|
y_axis_type = 'linear'
|
||||||
@@ -3274,28 +3295,28 @@ def interactive_agegroupcpchart(age,normalized=False):
|
|||||||
tools=TOOLS)
|
tools=TOOLS)
|
||||||
plot.sizing_mode = 'stretch_both'
|
plot.sizing_mode = 'stretch_both'
|
||||||
|
|
||||||
plot.line('duration','fitpowerfh',source=source,
|
plot.line('duration','fitpowerfh',source=sourcefit,
|
||||||
legend_label='Female HW',color='blue')
|
legend_label='Female HW',color='blue')
|
||||||
plot.line('duration','fitpowerfl',source=source,
|
plot.line('duration','fitpowerfl',source=sourcefit,
|
||||||
legend_label='Female LW',color='red')
|
legend_label='Female LW',color='red')
|
||||||
|
|
||||||
plot.line('duration','fitpowerml',source=source,
|
plot.line('duration','fitpowerml',source=sourcefit,
|
||||||
legend_label='Male LW',color='green')
|
legend_label='Male LW',color='green')
|
||||||
|
|
||||||
plot.line('duration','fitpowermh',source=source,
|
plot.line('duration','fitpowermh',source=sourcefit,
|
||||||
legend_label='Male HW',color='orange')
|
legend_label='Male HW',color='orange')
|
||||||
|
|
||||||
|
|
||||||
plot.circle('flduration','flpower',source=source,
|
plot.circle('flduration','flpower',source=sourcefl,
|
||||||
fill_color='red',size=15)
|
fill_color='red',size=15)
|
||||||
|
|
||||||
plot.circle('fhduration','fhpower',source=source,
|
plot.circle('fhduration','fhpower',source=sourcefh,
|
||||||
fill_color='blue',size=15)
|
fill_color='blue',size=15)
|
||||||
|
|
||||||
plot.circle('mlduration','mlpower',source=source,
|
plot.circle('mlduration','mlpower',source=sourceml,
|
||||||
fill_color='green',size=15)
|
fill_color='green',size=15)
|
||||||
|
|
||||||
plot.circle('mhduration','mhpower',source=source,
|
plot.circle('mhduration','mhpower',source=sourcemh,
|
||||||
fill_color='orange',size=15)
|
fill_color='orange',size=15)
|
||||||
|
|
||||||
plot.title.text = 'age '+str(age)
|
plot.title.text = 'age '+str(age)
|
||||||
@@ -3400,16 +3421,23 @@ def interactive_otwcpchart(powerdf,promember=0,rowername="",r=None,cpfit='data',
|
|||||||
CPmax = ratio*fitpower,
|
CPmax = ratio*fitpower,
|
||||||
duration = fitt/60.,
|
duration = fitt/60.,
|
||||||
ftime = ftime,
|
ftime = ftime,
|
||||||
workout = workouts,
|
# workout = workouts,
|
||||||
fitpowerwc = fitpowerwc,
|
fitpowerwc = fitpowerwc,
|
||||||
fitpowerexcellent = fitpowerexcellent,
|
fitpowerexcellent = fitpowerexcellent,
|
||||||
fitpowergood = fitpowergood,
|
fitpowergood = fitpowergood,
|
||||||
fitpowerfair = fitpowerfair,
|
fitpowerfair = fitpowerfair,
|
||||||
fitpoweraverage = fitpoweraverage,
|
fitpoweraverage = fitpoweraverage,
|
||||||
url = urls,
|
# url = urls,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sourceannot= ColumnDataSource(
|
||||||
|
data = dict(
|
||||||
|
workout = workouts,
|
||||||
|
url = urls,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# making the plot
|
# making the plot
|
||||||
plot = Figure(tools=TOOLS,x_axis_type=x_axis_type,
|
plot = Figure(tools=TOOLS,x_axis_type=x_axis_type,
|
||||||
plot_width=900,
|
plot_width=900,
|
||||||
@@ -3544,13 +3572,20 @@ def interactive_agegroup_plot(df,distance=2000,duration=None,
|
|||||||
data = dict(
|
data = dict(
|
||||||
age = age,
|
age = age,
|
||||||
power = power,
|
power = power,
|
||||||
age2 = age2,
|
#age2 = age2,
|
||||||
expo_vals = expo_vals,
|
#expo_vals = expo_vals,
|
||||||
season = season,
|
season = season,
|
||||||
name=name,
|
name=name,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sourcefit = ColumnDataSource(
|
||||||
|
data = dict(
|
||||||
|
age2 = age2,
|
||||||
|
expo_vals = expo_vals,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
||||||
|
|
||||||
plot = Figure(tools=TOOLS,plot_width=900)
|
plot = Figure(tools=TOOLS,plot_width=900)
|
||||||
@@ -3558,7 +3593,7 @@ def interactive_agegroup_plot(df,distance=2000,duration=None,
|
|||||||
plot.circle('age','power',source=source,fill_color='red',size=15,
|
plot.circle('age','power',source=source,fill_color='red',size=15,
|
||||||
legend_label='World Record')
|
legend_label='World Record')
|
||||||
|
|
||||||
plot.line(age2,expo_vals)
|
plot.line('age2','expo_vals',source=sourcefit)
|
||||||
plot.xaxis.axis_label = "Age"
|
plot.xaxis.axis_label = "Age"
|
||||||
plot.yaxis.axis_label = "Concept2 power"
|
plot.yaxis.axis_label = "Concept2 power"
|
||||||
plot.title.text = plottitle
|
plot.title.text = plottitle
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ except NameError:
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
warnings.filterwarnings("error",category=UserWarning)
|
#warnings.filterwarnings("error",category=UserWarning)
|
||||||
|
|
||||||
pytestmark = pytest.mark.django_db
|
pytestmark = pytest.mark.django_db
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from .statements import *
|
|||||||
nu = datetime.datetime.now()
|
nu = datetime.datetime.now()
|
||||||
|
|
||||||
from rowers.views import *
|
from rowers.views import *
|
||||||
|
from rowers.views.analysisviews import histodata
|
||||||
|
|
||||||
class WorkoutCompareTest(TestCase):
|
class WorkoutCompareTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@@ -1360,7 +1361,7 @@ 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 = 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)
|
||||||
|
|||||||
@@ -216,6 +216,9 @@ class ViewTest(TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
form = DocumentsForm(form_data,file_data)
|
form = DocumentsForm(form_data,file_data)
|
||||||
|
if not form.is_valid():
|
||||||
|
print(form.errors)
|
||||||
|
self.assertTrue(form.is_valid())
|
||||||
|
|
||||||
response = self.c.post('/rowers/workout/upload/', form_data, follow=True)
|
response = self.c.post('/rowers/workout/upload/', form_data, follow=True)
|
||||||
|
|
||||||
|
|||||||
@@ -1108,3 +1108,10 @@ def strfdelta(tdelta):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def request_is_ajax(request):
|
||||||
|
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
|
||||||
|
if settings.TESTING:
|
||||||
|
is_ajax = True
|
||||||
|
|
||||||
|
return is_ajax
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
|||||||
firstworkout = None
|
firstworkout = None
|
||||||
if id:
|
if id:
|
||||||
firstworkout = get_workout(id)
|
firstworkout = get_workout(id)
|
||||||
if not is_workout_team(request.user,firstworkout):
|
if not is_workout_team(request.user,firstworkout): # pragma: no cover
|
||||||
raise PermissionDenied("You are not allowed to use this workout")
|
raise PermissionDenied("You are not allowed to use this workout")
|
||||||
firstworkoutquery = Workout.objects.filter(id=encoder.decode_hex(id))
|
firstworkoutquery = Workout.objects.filter(id=encoder.decode_hex(id))
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
|||||||
options['userid'] = userid
|
options['userid'] = userid
|
||||||
try:
|
try:
|
||||||
workouttypes = options['workouttypes']
|
workouttypes = options['workouttypes']
|
||||||
except KeyError:
|
except KeyError: # pragma: no cover
|
||||||
workouttypes = ['rower','dynamic','slides']
|
workouttypes = ['rower','dynamic','slides']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -80,12 +80,12 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
|||||||
|
|
||||||
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
|
||||||
|
|
||||||
if 'startdate' in request.session:
|
if 'startdate' in request.session:
|
||||||
@@ -93,7 +93,7 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
|||||||
else:
|
else:
|
||||||
startdate=timezone.now()-datetime.timedelta(days=42)
|
startdate=timezone.now()-datetime.timedelta(days=42)
|
||||||
|
|
||||||
if function not in [c[0] for c in analysischoices]:
|
if function not in [c[0] for c in analysischoices]: # pragma: no cover
|
||||||
function = 'boxplot'
|
function = 'boxplot'
|
||||||
|
|
||||||
if 'enddate' in request.session:
|
if 'enddate' in request.session:
|
||||||
@@ -124,7 +124,7 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
|||||||
waterboattype = optionsform.cleaned_data['waterboattype']
|
waterboattype = optionsform.cleaned_data['waterboattype']
|
||||||
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':
|
||||||
waterboattype = [b[0] for b in mytypes.boattypes]
|
waterboattype = [b[0] for b in mytypes.boattypes]
|
||||||
@@ -132,7 +132,7 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
|||||||
|
|
||||||
if 'rankingonly' in optionsform.cleaned_data:
|
if 'rankingonly' in optionsform.cleaned_data:
|
||||||
rankingonly = optionsform.cleaned_data['rankingonly']
|
rankingonly = optionsform.cleaned_data['rankingonly']
|
||||||
else:
|
else: # pragma: no cover
|
||||||
rankingonly = False
|
rankingonly = False
|
||||||
|
|
||||||
options['modalities'] = modalities
|
options['modalities'] = modalities
|
||||||
@@ -156,7 +156,7 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
|||||||
selectedworkouts = cd['workouts']
|
selectedworkouts = cd['workouts']
|
||||||
ids = [int(w.id) for w in selectedworkouts]
|
ids = [int(w.id) for w in selectedworkouts]
|
||||||
options['ids'] = ids
|
options['ids'] = ids
|
||||||
else:
|
else: # pragma: no cover
|
||||||
ids = []
|
ids = []
|
||||||
options['ids'] = ids
|
options['ids'] = ids
|
||||||
else:
|
else:
|
||||||
@@ -170,14 +170,14 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
|||||||
|
|
||||||
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])
|
||||||
|
|
||||||
|
|
||||||
startdate = datetime.datetime.combine(startdate,datetime.time())
|
startdate = datetime.datetime.combine(startdate,datetime.time())
|
||||||
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
|
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
|
||||||
|
|
||||||
if enddate < startdate:
|
if enddate < startdate: # pragma: no cover
|
||||||
s = enddate
|
s = enddate
|
||||||
enddate = startdate
|
enddate = startdate
|
||||||
startdate = s
|
startdate = s
|
||||||
@@ -185,27 +185,27 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
|||||||
# make sure the dates are not naive
|
# make sure the dates are not naive
|
||||||
try:
|
try:
|
||||||
startdate = pytz.utc.localize(startdate)
|
startdate = pytz.utc.localize(startdate)
|
||||||
except (ValueError, AttributeError):
|
except (ValueError, AttributeError): # pragma: no cover
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
enddate = pytz.utc.localize(enddate)
|
enddate = pytz.utc.localize(enddate)
|
||||||
except (ValueError, AttributeError):
|
except (ValueError, AttributeError): # pragma: no cover
|
||||||
pass
|
pass
|
||||||
|
|
||||||
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])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if theteam is not None and (theteam.viewing == 'allmembers' or theteam.manager == request.user):
|
if theteam is not None and (theteam.viewing == 'allmembers' or theteam.manager == request.user): # pragma: no cover
|
||||||
workouts = Workout.objects.filter(team=theteam,
|
workouts = Workout.objects.filter(team=theteam,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate,
|
startdatetime__lte=enddate,
|
||||||
workouttype__in=modalities,
|
workouttype__in=modalities,
|
||||||
)
|
)
|
||||||
elif theteam is not None and theteam.viewing == 'coachonly':
|
elif theteam is not None and theteam.viewing == 'coachonly': # pragma: no cover
|
||||||
workouts = Workout.objects.filter(team=theteam,user=r,
|
workouts = Workout.objects.filter(team=theteam,user=r,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate,
|
startdatetime__lte=enddate,
|
||||||
@@ -224,11 +224,11 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
|||||||
).exclude(boattype__in=negtypes)
|
).exclude(boattype__in=negtypes)
|
||||||
|
|
||||||
|
|
||||||
if rankingonly:
|
if rankingonly: # pragma: no cover
|
||||||
workouts = workouts.exclude(rankingpiece=False)
|
workouts = workouts.exclude(rankingpiece=False)
|
||||||
|
|
||||||
query = request.POST.get('q')
|
query = request.POST.get('q')
|
||||||
if query:
|
if query: # pragma: no cover
|
||||||
query_list = query.split()
|
query_list = query.split()
|
||||||
try:
|
try:
|
||||||
workouts = workouts.filter(
|
workouts = workouts.filter(
|
||||||
@@ -334,7 +334,7 @@ def trendflexdata(workouts, options,userid=0):
|
|||||||
# prepare data frame
|
# prepare data frame
|
||||||
datadf,extracols = dataprep.read_cols_df_sql(ids,fieldlist)
|
datadf,extracols = dataprep.read_cols_df_sql(ids,fieldlist)
|
||||||
|
|
||||||
if xparam == groupby:
|
if xparam == groupby: # pragma: no cover
|
||||||
datadf['groupby'] = datadf[xparam]
|
datadf['groupby'] = datadf[xparam]
|
||||||
groupy = 'groupby'
|
groupy = 'groupby'
|
||||||
|
|
||||||
@@ -376,9 +376,9 @@ def trendflexdata(workouts, options,userid=0):
|
|||||||
datadf[groupby].max()+binsize,
|
datadf[groupby].max()+binsize,
|
||||||
binsize)
|
binsize)
|
||||||
groups = datadf.groupby(pd.cut(datadf[groupby],bins,labels=False))
|
groups = datadf.groupby(pd.cut(datadf[groupby],bins,labels=False))
|
||||||
except (ValueError, AttributeError):
|
except (ValueError, AttributeError): # pragma: no cover
|
||||||
return ('','Error: not enough data')
|
return ('','Error: not enough data')
|
||||||
else:
|
else: # pragma: no cover
|
||||||
bins = np.arange(datadf['days ago'].min()-binsize,
|
bins = np.arange(datadf['days ago'].min()-binsize,
|
||||||
datadf['days ago'].max()+binsize,
|
datadf['days ago'].max()+binsize,
|
||||||
binsize,
|
binsize,
|
||||||
@@ -407,7 +407,7 @@ def trendflexdata(workouts, options,userid=0):
|
|||||||
yerror.dropna(inplace=True)
|
yerror.dropna(inplace=True)
|
||||||
groupsize.dropna(inplace=True)
|
groupsize.dropna(inplace=True)
|
||||||
|
|
||||||
if len(groupsize) == 0:
|
if len(groupsize) == 0: # pragma: no cover
|
||||||
messages.error(request,'No data in selection')
|
messages.error(request,'No data in selection')
|
||||||
url = reverse(user_multiflex_select)
|
url = reverse(user_multiflex_select)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
@@ -436,15 +436,15 @@ def trendflexdata(workouts, options,userid=0):
|
|||||||
df['groupval'].loc[mask] = np.nan
|
df['groupval'].loc[mask] = np.nan
|
||||||
|
|
||||||
groupcols = df['groupval']
|
groupcols = df['groupval']
|
||||||
except (ValueError, AttributeError):
|
except (ValueError, AttributeError): # pragma: no cover
|
||||||
df['groupval'] = groups.mean()[groupby].fillna(value=0)
|
df['groupval'] = groups.mean()[groupby].fillna(value=0)
|
||||||
df['groupval'].loc[mask] = np.nan
|
df['groupval'].loc[mask] = np.nan
|
||||||
groupcols = df['groupval']
|
groupcols = df['groupval']
|
||||||
except KeyError:
|
except KeyError: # pragma: no cover
|
||||||
messages.error(request,'Data selection error')
|
messages.error(request,'Data selection error')
|
||||||
url = reverse(user_multiflex_select)
|
url = reverse(user_multiflex_select)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
else:
|
else: # pragma: no cover
|
||||||
try:
|
try:
|
||||||
dates = groups.min()[groupby]
|
dates = groups.min()[groupby]
|
||||||
dates.loc[mask] = np.nan
|
dates.loc[mask] = np.nan
|
||||||
@@ -459,7 +459,7 @@ def trendflexdata(workouts, options,userid=0):
|
|||||||
|
|
||||||
groupcols = (groupcols-groupcols.min())/(groupcols.max()-groupcols.min())
|
groupcols = (groupcols-groupcols.min())/(groupcols.max()-groupcols.min())
|
||||||
|
|
||||||
if aantal == 1:
|
if aantal == 1: # pragma: no cover
|
||||||
groupcols = np.array([1.])
|
groupcols = np.array([1.])
|
||||||
|
|
||||||
|
|
||||||
@@ -471,7 +471,7 @@ def trendflexdata(workouts, options,userid=0):
|
|||||||
legcolors = range_to_color_hex(clegendx,palette=palette)
|
legcolors = range_to_color_hex(clegendx,palette=palette)
|
||||||
if groupby != 'date':
|
if groupby != 'date':
|
||||||
clegendy = df['groupval'].min()+clegendx*(df['groupval'].max()-df['groupval'].min())
|
clegendy = df['groupval'].min()+clegendx*(df['groupval'].max()-df['groupval'].min())
|
||||||
else:
|
else: # pragma: no cover
|
||||||
clegendy = df.index.min()+clegendx*(df.index.max()-df.index.min())
|
clegendy = df.index.min()+clegendx*(df.index.max()-df.index.min())
|
||||||
|
|
||||||
|
|
||||||
@@ -481,7 +481,7 @@ def trendflexdata(workouts, options,userid=0):
|
|||||||
|
|
||||||
if userid == 0:
|
if userid == 0:
|
||||||
extratitle = ''
|
extratitle = ''
|
||||||
else:
|
else: # pragma: no cover
|
||||||
u = User.objects.get(id=userid)
|
u = User.objects.get(id=userid)
|
||||||
extratitle = ' '+u.first_name+' '+u.last_name
|
extratitle = ' '+u.first_name+' '+u.last_name
|
||||||
|
|
||||||
@@ -888,7 +888,8 @@ def boxplotdata(workouts,options):
|
|||||||
redirect_field_name=None)
|
redirect_field_name=None)
|
||||||
@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):
|
||||||
if not request.is_ajax():
|
is_ajax = request_is_ajax(request)
|
||||||
|
if not is_ajax:
|
||||||
url = reverse('analysis_new')
|
url = reverse('analysis_new')
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
@@ -1581,9 +1582,7 @@ def goldmedalscores_view(request,userid=0,
|
|||||||
startdate=timezone.now()-timezone.timedelta(days=365),
|
startdate=timezone.now()-timezone.timedelta(days=365),
|
||||||
enddate=timezone.now()):
|
enddate=timezone.now()):
|
||||||
|
|
||||||
is_ajax = False
|
is_ajax = request_is_ajax(request)
|
||||||
if request.is_ajax():
|
|
||||||
is_ajax = True
|
|
||||||
|
|
||||||
therower = getrequestrower(request,userid=userid)
|
therower = getrequestrower(request,userid=userid)
|
||||||
theuser = therower.user
|
theuser = therower.user
|
||||||
@@ -1649,9 +1648,7 @@ def performancemanager_view(request,userid=0,mode='rower',
|
|||||||
startdate=timezone.now()-timezone.timedelta(days=365),
|
startdate=timezone.now()-timezone.timedelta(days=365),
|
||||||
enddate=timezone.now()):
|
enddate=timezone.now()):
|
||||||
|
|
||||||
is_ajax = False
|
is_ajax = request_is_ajax(request)
|
||||||
if request.is_ajax():
|
|
||||||
is_ajax = True
|
|
||||||
|
|
||||||
|
|
||||||
therower = getrequestrower(request,userid=userid)
|
therower = getrequestrower(request,userid=userid)
|
||||||
@@ -4914,7 +4911,8 @@ def alert_report_view(request,id=0,userid=0,nperiod=0):
|
|||||||
|
|
||||||
stats = alert_get_stats(alert,nperiod=nperiod)
|
stats = alert_get_stats(alert,nperiod=nperiod)
|
||||||
|
|
||||||
if request.is_ajax():
|
is_ajax = request_is_ajax(request)
|
||||||
|
if not is_ajax:
|
||||||
return JSONResponse({
|
return JSONResponse({
|
||||||
"stats":stats,
|
"stats":stats,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1197,7 +1197,8 @@ from rowers.utils import (
|
|||||||
geo_distance,serialize_list,deserialize_list,uniqify,
|
geo_distance,serialize_list,deserialize_list,uniqify,
|
||||||
str2bool,range_to_color_hex,absolute,myqueue,get_call,
|
str2bool,range_to_color_hex,absolute,myqueue,get_call,
|
||||||
calculate_age,rankingdistances,rankingdurations,
|
calculate_age,rankingdistances,rankingdurations,
|
||||||
is_ranking_piece,my_dict_from_instance,wavg,NoTokenError
|
is_ranking_piece,my_dict_from_instance,wavg,NoTokenError,
|
||||||
|
request_is_ajax
|
||||||
)
|
)
|
||||||
|
|
||||||
import rowers.datautils as datautils
|
import rowers.datautils as datautils
|
||||||
|
|||||||
@@ -4586,9 +4586,8 @@ def workout_map_view(request,id=0):
|
|||||||
# Image upload
|
# Image upload
|
||||||
@permission_required('workout.change_workout',fn=get_workout_by_opaqueid,raise_exception=True)
|
@permission_required('workout.change_workout',fn=get_workout_by_opaqueid,raise_exception=True)
|
||||||
def workout_uploadimage_view(request,id): # pragma: no cover
|
def workout_uploadimage_view(request,id): # pragma: no cover
|
||||||
is_ajax = False # pragma: no cover
|
is_ajax = request_is_ajax(request)
|
||||||
if request.is_ajax():
|
|
||||||
is_ajax = True
|
|
||||||
|
|
||||||
r = getrower(request.user)
|
r = getrower(request.user)
|
||||||
|
|
||||||
@@ -4727,9 +4726,8 @@ def workout_add_chart_view(request,id,plotnr=1):
|
|||||||
@login_required
|
@login_required
|
||||||
@permission_required('workout.change_workout',fn=get_workout_by_opaqueid,raise_exception=True)
|
@permission_required('workout.change_workout',fn=get_workout_by_opaqueid,raise_exception=True)
|
||||||
def workout_toggle_ranking(request,id=0):
|
def workout_toggle_ranking(request,id=0):
|
||||||
is_ajax = False
|
is_ajax = request_is_ajax(request)
|
||||||
if request.is_ajax(): # pragma: no cover
|
|
||||||
is_ajax = True
|
|
||||||
|
|
||||||
row = get_workout_by_opaqueid(request,id)
|
row = get_workout_by_opaqueid(request,id)
|
||||||
|
|
||||||
@@ -4980,9 +4978,7 @@ def workout_upload_view(request,
|
|||||||
},
|
},
|
||||||
raceid=0):
|
raceid=0):
|
||||||
|
|
||||||
is_ajax = False
|
is_ajax = request_is_ajax(request)
|
||||||
if request.is_ajax(): # pragma: no cover
|
|
||||||
is_ajax = True
|
|
||||||
|
|
||||||
r = getrower(request.user)
|
r = getrower(request.user)
|
||||||
if r.rowerplan == 'freecoach': # pragma: no cover
|
if r.rowerplan == 'freecoach': # pragma: no cover
|
||||||
|
|||||||
Reference in New Issue
Block a user