analysisviews pep
This commit is contained in:
@@ -1,11 +1,7 @@
|
|||||||
import time
|
|
||||||
from rowers.forms import analysischoices
|
from rowers.forms import analysischoices
|
||||||
from django.contrib.staticfiles import finders
|
|
||||||
from rowers.views.statements import *
|
from rowers.views.statements import *
|
||||||
|
|
||||||
import collections
|
from jinja2 import Environment, FileSystemLoader
|
||||||
import simplejson
|
|
||||||
from jinja2 import Template, Environment, FileSystemLoader
|
|
||||||
from rowers.rower_rules import can_view_session
|
from rowers.rower_rules import can_view_session
|
||||||
|
|
||||||
|
|
||||||
@@ -28,10 +24,16 @@ defaultoptions = {
|
|||||||
|
|
||||||
|
|
||||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
message="This functionality requires a Pro plan or higher."
|
||||||
|
" If you are already a Pro user,"
|
||||||
|
" please log in to access this functionality",
|
||||||
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',
|
||||||
def analysis_new(request, userid=0, function='boxplot', teamid=0, id='', session=0):
|
fn=get_user_by_userid,
|
||||||
|
raise_exception=True)
|
||||||
|
def analysis_new(request,
|
||||||
|
userid=0,
|
||||||
|
function='boxplot', teamid=0, id='', session=0):
|
||||||
r = getrequestrower(request, userid=userid)
|
r = getrequestrower(request, userid=userid)
|
||||||
user = r.user
|
user = r.user
|
||||||
userid = user.id
|
userid = user.id
|
||||||
@@ -62,10 +64,6 @@ def analysis_new(request, userid=0, function='boxplot', teamid=0, id='', session
|
|||||||
options = defaultoptions
|
options = defaultoptions
|
||||||
|
|
||||||
options['userid'] = userid
|
options['userid'] = userid
|
||||||
try:
|
|
||||||
workouttypes = options['workouttypes']
|
|
||||||
except KeyError: # pragma: no cover
|
|
||||||
workouttypes = ['rower', 'dynamic', 'slides']
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
modalities = options['modalities']
|
modalities = options['modalities']
|
||||||
@@ -79,11 +77,6 @@ def analysis_new(request, userid=0, function='boxplot', teamid=0, id='', session
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
worldclass = False
|
worldclass = False
|
||||||
|
|
||||||
try:
|
|
||||||
includereststrokes = options['includereststrokes']
|
|
||||||
except KeyError: # pragma: no cover
|
|
||||||
includereststrokes = False
|
|
||||||
|
|
||||||
if 'startdate' in request.session:
|
if 'startdate' in request.session:
|
||||||
startdate = iso8601.parse_date(request.session['startdate'])
|
startdate = iso8601.parse_date(request.session['startdate'])
|
||||||
else:
|
else:
|
||||||
@@ -97,8 +90,6 @@ def analysis_new(request, userid=0, function='boxplot', teamid=0, id='', session
|
|||||||
else:
|
else:
|
||||||
enddate = timezone.now()
|
enddate = timezone.now()
|
||||||
|
|
||||||
workstrokesonly = not includereststrokes
|
|
||||||
|
|
||||||
waterboattype = mytypes.waterboattype
|
waterboattype = mytypes.waterboattype
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
@@ -296,15 +287,9 @@ def trendflexdata(workouts, options, userid=0):
|
|||||||
workmin = options['workmin']
|
workmin = options['workmin']
|
||||||
workmax = options['workmax']
|
workmax = options['workmax']
|
||||||
ploterrorbars = options['ploterrorbars']
|
ploterrorbars = options['ploterrorbars']
|
||||||
cpfit = options['cpfit']
|
|
||||||
piece = options['piece']
|
|
||||||
ids = options['ids']
|
ids = options['ids']
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
|
|
||||||
labeldict = {
|
|
||||||
int(w.id): w.__str__() for w in workouts
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldlist, fielddict = dataprep.getstatsfields()
|
fieldlist, fielddict = dataprep.getstatsfields()
|
||||||
fieldlist = [xparam, yparam, groupby,
|
fieldlist = [xparam, yparam, groupby,
|
||||||
'workoutid', 'spm', 'driveenergy',
|
'workoutid', 'spm', 'driveenergy',
|
||||||
@@ -315,7 +300,7 @@ def trendflexdata(workouts, options, userid=0):
|
|||||||
|
|
||||||
if xparam == groupby: # pragma: no cover
|
if xparam == groupby: # pragma: no cover
|
||||||
datadf['groupby'] = datadf[xparam]
|
datadf['groupby'] = datadf[xparam]
|
||||||
groupy = 'groupby'
|
groupby = 'groupby'
|
||||||
|
|
||||||
datadf = dataprep.clean_df_stats(datadf, workstrokesonly=workstrokesonly)
|
datadf = dataprep.clean_df_stats(datadf, workstrokesonly=workstrokesonly)
|
||||||
|
|
||||||
@@ -497,16 +482,14 @@ def flexalldata(workouts, options):
|
|||||||
def histodata(workouts, options):
|
def histodata(workouts, options):
|
||||||
includereststrokes = options['includereststrokes']
|
includereststrokes = options['includereststrokes']
|
||||||
plotfield = options['plotfield']
|
plotfield = options['plotfield']
|
||||||
function = options['function']
|
|
||||||
spmmin = options['spmmin']
|
spmmin = options['spmmin']
|
||||||
spmmax = options['spmmax']
|
spmmax = options['spmmax']
|
||||||
workmin = options['workmin']
|
workmin = options['workmin']
|
||||||
workmax = options['workmax']
|
workmax = options['workmax']
|
||||||
|
|
||||||
workstrokesonly = not includereststrokes
|
|
||||||
|
|
||||||
script, div = interactive_histoall(workouts, plotfield, includereststrokes,
|
script, div = interactive_histoall(workouts, plotfield, includereststrokes,
|
||||||
spmmin=spmmin, spmmax=spmmax, workmin=workmin, workmax=workmax)
|
spmmin=spmmin, spmmax=spmmax,
|
||||||
|
workmin=workmin, workmax=workmax)
|
||||||
|
|
||||||
scripta = script.split('\n')[2:-1]
|
scripta = script.split('\n')[2:-1]
|
||||||
script = ''.join(scripta)
|
script = ''.join(scripta)
|
||||||
@@ -522,7 +505,6 @@ def cpdata(workouts, options):
|
|||||||
u = User.objects.get(id=userid)
|
u = User.objects.get(id=userid)
|
||||||
r = u.rower
|
r = u.rower
|
||||||
|
|
||||||
ids = [w.id for w in workouts]
|
|
||||||
delta, cpvalue, avgpower, workoutnames, urls = dataprep.fetchcp_new(
|
delta, cpvalue, avgpower, workoutnames, urls = dataprep.fetchcp_new(
|
||||||
r, workouts)
|
r, workouts)
|
||||||
|
|
||||||
@@ -565,7 +547,6 @@ def cpdata(workouts, options):
|
|||||||
if r.birthdate:
|
if r.birthdate:
|
||||||
age = calculate_age(r.birthdate)
|
age = calculate_age(r.birthdate)
|
||||||
else: # pragma: no cover
|
else: # pragma: no cover
|
||||||
worldclasspower = None
|
|
||||||
age = 0
|
age = 0
|
||||||
|
|
||||||
agerecords = CalcAgePerformance.objects.filter(
|
agerecords = CalcAgePerformance.objects.filter(
|
||||||
@@ -597,17 +578,11 @@ def cpdata(workouts, options):
|
|||||||
div = res[1]
|
div = res[1]
|
||||||
p1 = res[2]
|
p1 = res[2]
|
||||||
ratio = res[3]
|
ratio = res[3]
|
||||||
paulslope = 1
|
|
||||||
paulintercept = 1
|
|
||||||
message = res[4]
|
|
||||||
else: # pragma: no cover
|
else: # pragma: no cover
|
||||||
script = ''
|
script = ''
|
||||||
div = '<p>No ranking pieces found.</p>'
|
div = '<p>No ranking pieces found.</p>'
|
||||||
paulslope = 1
|
|
||||||
paulintercept = 1
|
|
||||||
p1 = [1, 1, 1, 1]
|
p1 = [1, 1, 1, 1]
|
||||||
ratio = 1
|
ratio = 1
|
||||||
message = ""
|
|
||||||
|
|
||||||
scripta = script.split('\n')[2:-1]
|
scripta = script.split('\n')[2:-1]
|
||||||
script = ''.join(scripta)
|
script = ''.join(scripta)
|
||||||
@@ -677,23 +652,12 @@ def cpdata(workouts, options):
|
|||||||
|
|
||||||
def statsdata(workouts, options):
|
def statsdata(workouts, options):
|
||||||
includereststrokes = options['includereststrokes']
|
includereststrokes = options['includereststrokes']
|
||||||
spmmin = options['spmmin']
|
|
||||||
spmmax = options['spmmax']
|
|
||||||
workmin = options['workmin']
|
|
||||||
workmax = options['workmax']
|
|
||||||
ids = options['ids']
|
ids = options['ids']
|
||||||
userid = options['userid']
|
|
||||||
plotfield = options['plotfield']
|
|
||||||
function = options['function']
|
|
||||||
|
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
|
|
||||||
ids = [w.id for w in workouts]
|
ids = [w.id for w in workouts]
|
||||||
|
|
||||||
datamapping = {
|
|
||||||
w.id: w.date for w in workouts
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldlist, fielddict = dataprep.getstatsfields()
|
fieldlist, fielddict = dataprep.getstatsfields()
|
||||||
# prepare data frame
|
# prepare data frame
|
||||||
datadf, extracols = dataprep.read_cols_df_sql(ids, fieldlist)
|
datadf, extracols = dataprep.read_cols_df_sql(ids, fieldlist)
|
||||||
@@ -791,12 +755,8 @@ def boxplotdata(workouts, options):
|
|||||||
ids = options['ids']
|
ids = options['ids']
|
||||||
userid = options['userid']
|
userid = options['userid']
|
||||||
plotfield = options['plotfield']
|
plotfield = options['plotfield']
|
||||||
function = options['function']
|
|
||||||
|
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
labeldict = {
|
|
||||||
int(w.id): w.__str__() for w in workouts
|
|
||||||
}
|
|
||||||
|
|
||||||
datemapping = {
|
datemapping = {
|
||||||
w.id: w.date for w in workouts
|
w.id: w.date for w in workouts
|
||||||
@@ -838,7 +798,8 @@ def boxplotdata(workouts, options):
|
|||||||
|
|
||||||
script, div = interactive_boxchart(datadf, plotfield,
|
script, div = interactive_boxchart(datadf, plotfield,
|
||||||
extratitle=extratitle,
|
extratitle=extratitle,
|
||||||
spmmin=spmmin, spmmax=spmmax, workmin=workmin, workmax=workmax)
|
spmmin=spmmin, spmmax=spmmax,
|
||||||
|
workmin=workmin, workmax=workmax)
|
||||||
|
|
||||||
scripta = script.split('\n')[2:-1]
|
scripta = script.split('\n')[2:-1]
|
||||||
script = ''.join(scripta)
|
script = ''.join(scripta)
|
||||||
@@ -847,7 +808,8 @@ def boxplotdata(workouts, options):
|
|||||||
|
|
||||||
|
|
||||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
message="This functionality requires a Pro plan or higher."
|
||||||
|
" If you are already a Pro user, please log in to access this functionality",
|
||||||
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):
|
||||||
@@ -922,7 +884,8 @@ def planrequired_view(request):
|
|||||||
|
|
||||||
|
|
||||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
message="This functionality requires a Pro plan or higher."
|
||||||
|
" If you are already a Pro user, please log in to access this functionality",
|
||||||
redirect_field_name=None)
|
redirect_field_name=None)
|
||||||
def create_marker_workouts_view(request, userid=0,
|
def create_marker_workouts_view(request, userid=0,
|
||||||
startdate=timezone.now()-timezone.timedelta(days=42),
|
startdate=timezone.now()-timezone.timedelta(days=42),
|
||||||
@@ -936,7 +899,7 @@ def create_marker_workouts_view(request, userid=0,
|
|||||||
duplicate=False).order_by('date')
|
duplicate=False).order_by('date')
|
||||||
|
|
||||||
for workout in workouts:
|
for workout in workouts:
|
||||||
w2 = dataprep.check_marker(workout)
|
_ = dataprep.check_marker(workout)
|
||||||
|
|
||||||
url = reverse('goldmedalscores_view',
|
url = reverse('goldmedalscores_view',
|
||||||
kwargs={
|
kwargs={
|
||||||
@@ -946,7 +909,8 @@ def create_marker_workouts_view(request, userid=0,
|
|||||||
|
|
||||||
|
|
||||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
message="This functionality requires a Pro plan or higher."
|
||||||
|
" If you are already a Pro user, please log in to access this functionality",
|
||||||
redirect_field_name=None)
|
redirect_field_name=None)
|
||||||
def goldmedalscores_view(request, userid=0,
|
def goldmedalscores_view(request, userid=0,
|
||||||
startdate=timezone.now()-timezone.timedelta(days=365),
|
startdate=timezone.now()-timezone.timedelta(days=365),
|
||||||
@@ -1010,13 +974,11 @@ def goldmedalscores_view(request, userid=0,
|
|||||||
|
|
||||||
|
|
||||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
message="This functionality requires a Pro plan or higher."
|
||||||
|
" If you are already a Pro user, please log in to access this functionality",
|
||||||
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 trainingzones_view(request, userid=0):
|
def trainingzones_view(request, userid=0):
|
||||||
|
|
||||||
is_ajax = request_is_ajax(request)
|
|
||||||
|
|
||||||
r = getrequestrower(request, userid=userid)
|
r = getrequestrower(request, userid=userid)
|
||||||
|
|
||||||
enddate = timezone.now()
|
enddate = timezone.now()
|
||||||
@@ -1126,7 +1088,8 @@ def trainingzones_view_data(request, userid=0):
|
|||||||
|
|
||||||
|
|
||||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
message="This functionality requires a Pro plan or higher."
|
||||||
|
" If you are already a Pro user, please log in to access this functionality",
|
||||||
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 performancemanager_view(request, userid=0, mode='rower',
|
def performancemanager_view(request, userid=0, mode='rower',
|
||||||
@@ -1140,10 +1103,8 @@ def performancemanager_view(request, userid=0, mode='rower',
|
|||||||
|
|
||||||
kfitness = therower.kfit
|
kfitness = therower.kfit
|
||||||
kfatigue = therower.kfatigue
|
kfatigue = therower.kfatigue
|
||||||
fitnesstest = 20
|
|
||||||
metricchoice = 'hrtss'
|
metricchoice = 'hrtss'
|
||||||
modelchoice = 'tsb'
|
|
||||||
usegoldmedalstandard = False
|
|
||||||
doform = therower.showfresh
|
doform = therower.showfresh
|
||||||
dofatigue = therower.showfit
|
dofatigue = therower.showfit
|
||||||
|
|
||||||
@@ -1223,8 +1184,6 @@ def ajax_agegrouprecords(request,
|
|||||||
weightcategory='hwt',
|
weightcategory='hwt',
|
||||||
userid=0):
|
userid=0):
|
||||||
|
|
||||||
wcdurations = []
|
|
||||||
wcpower = []
|
|
||||||
durations = [1, 4, 30, 60]
|
durations = [1, 4, 30, 60]
|
||||||
distances = [100, 500, 1000, 2000, 5000, 6000, 10000, 21097, 42195]
|
distances = [100, 500, 1000, 2000, 5000, 6000, 10000, 21097, 42195]
|
||||||
|
|
||||||
@@ -1320,7 +1279,6 @@ def rankings_view2(request, userid=0,
|
|||||||
if r.birthdate:
|
if r.birthdate:
|
||||||
age = calculate_age(r.birthdate)
|
age = calculate_age(r.birthdate)
|
||||||
else:
|
else:
|
||||||
worldclasspower = None
|
|
||||||
age = 0
|
age = 0
|
||||||
|
|
||||||
agerecords = CalcAgePerformance.objects.filter(
|
agerecords = CalcAgePerformance.objects.filter(
|
||||||
@@ -1393,7 +1351,6 @@ def rankings_view2(request, userid=0,
|
|||||||
try:
|
try:
|
||||||
r = getrower(theuser)
|
r = getrower(theuser)
|
||||||
except Rower.DoesNotExist: # pragma: no cover
|
except Rower.DoesNotExist: # pragma: no cover
|
||||||
allergworkouts = []
|
|
||||||
r = 0
|
r = 0
|
||||||
|
|
||||||
uu = theuser
|
uu = theuser
|
||||||
@@ -1401,7 +1358,6 @@ def rankings_view2(request, userid=0,
|
|||||||
# test to fix bug
|
# test to fix bug
|
||||||
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))
|
||||||
#enddate = enddate+datetime.timedelta(days=1)
|
|
||||||
startdate = arrow.get(startdate).datetime
|
startdate = arrow.get(startdate).datetime
|
||||||
enddate = arrow.get(enddate).datetime
|
enddate = arrow.get(enddate).datetime
|
||||||
|
|
||||||
@@ -1469,11 +1425,6 @@ def rankings_view2(request, userid=0,
|
|||||||
paulintercept = res[3]
|
paulintercept = res[3]
|
||||||
p1 = res[4]
|
p1 = res[4]
|
||||||
message = res[5]
|
message = res[5]
|
||||||
try:
|
|
||||||
testcalc = pd.Series(res[6], dtype='float')*3
|
|
||||||
except TypeError: # pragma: no cover
|
|
||||||
age = 0
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
script = ''
|
script = ''
|
||||||
div = '<p>No ranking pieces found.</p>'
|
div = '<p>No ranking pieces found.</p>'
|
||||||
@@ -1582,19 +1533,19 @@ def rankings_view2(request, userid=0,
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# CP model
|
# CP model
|
||||||
pwr = p1[0]/(1+t/p1[2])
|
pwr = p1[0] / (1 + t / p1[2])
|
||||||
pwr += p1[1]/(1+t/p1[3])
|
pwr += p1[1] / (1 + t / p1[3])
|
||||||
|
|
||||||
if pwr <= 0: # pragma: no cover
|
if pwr <= 0: # pragma: no cover
|
||||||
pwr = 50.
|
pwr = 50.
|
||||||
|
|
||||||
velo = (pwr/2.8)**(1./3.)
|
velo = (pwr / 2.8)**(1. / 3.)
|
||||||
|
|
||||||
if np.isnan(velo) or velo <= 0: # pragma: no cover
|
if np.isnan(velo) or velo <= 0: # pragma: no cover
|
||||||
velo = 1.0
|
velo = 1.0
|
||||||
|
|
||||||
d = t*velo
|
d = t * velo
|
||||||
p = 500./velo
|
p = 500. / velo
|
||||||
a = {'distance': int(d),
|
a = {'distance': int(d),
|
||||||
'duration': timedeltaconv(t),
|
'duration': timedeltaconv(t),
|
||||||
'pace': timedeltaconv(p),
|
'pace': timedeltaconv(p),
|
||||||
@@ -1653,7 +1604,7 @@ def rankings_view2(request, userid=0,
|
|||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def otecp_toadmin_view(request, theuser=0,
|
def otecp_toadmin_view(request, theuser=0,
|
||||||
startdate=timezone.now()-datetime.timedelta(days=365),
|
startdate=timezone.now() - datetime.timedelta(days=365),
|
||||||
enddate=timezone.now(),
|
enddate=timezone.now(),
|
||||||
startdatestring="",
|
startdatestring="",
|
||||||
enddatestring="",
|
enddatestring="",
|
||||||
@@ -1710,13 +1661,13 @@ def otecp_toadmin_view(request, theuser=0,
|
|||||||
powerdf.drop_duplicates(subset='Delta', keep='first', inplace=True)
|
powerdf.drop_duplicates(subset='Delta', keep='first', inplace=True)
|
||||||
powerdf.to_csv(csvfilename)
|
powerdf.to_csv(csvfilename)
|
||||||
|
|
||||||
res = myqueue(queuehigh,
|
_ = myqueue(queuehigh,
|
||||||
handle_sendemailfile,
|
handle_sendemailfile,
|
||||||
'Sander',
|
'Sander',
|
||||||
'Roosendaal',
|
'Roosendaal',
|
||||||
'roosendaalsander@gmail.com',
|
'roosendaalsander@gmail.com',
|
||||||
csvfilename,
|
csvfilename,
|
||||||
delete=True)
|
delete=True)
|
||||||
|
|
||||||
successmessage = "The CSV file was sent to the site admin per email"
|
successmessage = "The CSV file was sent to the site admin per email"
|
||||||
messages.info(request, successmessage)
|
messages.info(request, successmessage)
|
||||||
@@ -1727,7 +1678,7 @@ def otecp_toadmin_view(request, theuser=0,
|
|||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def otwcp_toadmin_view(request, theuser=0,
|
def otwcp_toadmin_view(request, theuser=0,
|
||||||
startdate=timezone.now()-datetime.timedelta(days=365),
|
startdate=timezone.now() - datetime.timedelta(days=365),
|
||||||
enddate=timezone.now(),
|
enddate=timezone.now(),
|
||||||
startdatestring="",
|
startdatestring="",
|
||||||
enddatestring="",
|
enddatestring="",
|
||||||
@@ -1780,13 +1731,13 @@ def otwcp_toadmin_view(request, theuser=0,
|
|||||||
powerdf.drop_duplicates(subset='Delta', keep='first', inplace=True)
|
powerdf.drop_duplicates(subset='Delta', keep='first', inplace=True)
|
||||||
powerdf.to_csv(csvfilename)
|
powerdf.to_csv(csvfilename)
|
||||||
|
|
||||||
res = myqueue(queuehigh,
|
_ = myqueue(queuehigh,
|
||||||
handle_sendemailfile,
|
handle_sendemailfile,
|
||||||
'Sander',
|
'Sander',
|
||||||
'Roosendaal',
|
'Roosendaal',
|
||||||
'roosendaalsander@gmail.com',
|
'roosendaalsander@gmail.com',
|
||||||
csvfilename,
|
csvfilename,
|
||||||
delete=True)
|
delete=True)
|
||||||
|
|
||||||
successmessage = "The CSV file was sent to the site admin per email"
|
successmessage = "The CSV file was sent to the site admin per email"
|
||||||
messages.info(request, successmessage)
|
messages.info(request, successmessage)
|
||||||
@@ -1822,7 +1773,7 @@ def agegrouprecordview(request, sex='male', weightcategory='hwt',
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
duration = int(duration)*60
|
duration = int(duration) * 60
|
||||||
df = pd.DataFrame(
|
df = pd.DataFrame(
|
||||||
list(
|
list(
|
||||||
C2WorldClassAgePerformance.objects.filter(
|
C2WorldClassAgePerformance.objects.filter(
|
||||||
@@ -1844,11 +1795,6 @@ def agegrouprecordview(request, sex='male', weightcategory='hwt',
|
|||||||
'the_div': div,
|
'the_div': div,
|
||||||
})
|
})
|
||||||
|
|
||||||
# alert overview view
|
|
||||||
# @user_passes_test(ispromember, login_url="/rowers/paidplans",
|
|
||||||
# message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
|
||||||
# redirect_field_name=None)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@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)
|
||||||
@@ -1885,7 +1831,8 @@ def alerts_view(request, userid=0):
|
|||||||
|
|
||||||
|
|
||||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
message="This functionality requires a Pro plan or higher."
|
||||||
|
" If you are already a Pro user, please log in to access this functionality",
|
||||||
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 alert_create_view(request, userid=0):
|
def alert_create_view(request, userid=0):
|
||||||
@@ -1926,7 +1873,8 @@ def alert_create_view(request, userid=0):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
result, message = create_alert(request.user, r, measured, period=period, emailalert=emailalert,
|
result, message = create_alert(request.user, r, measured,
|
||||||
|
period=period, emailalert=emailalert,
|
||||||
reststrokes=reststrokes, workouttype=workouttype,
|
reststrokes=reststrokes, workouttype=workouttype,
|
||||||
boattype=boattype,
|
boattype=boattype,
|
||||||
filter=filters,
|
filter=filters,
|
||||||
@@ -2027,7 +1975,8 @@ def alert_report_view(request, id=0, userid=0, nperiod=0):
|
|||||||
|
|
||||||
|
|
||||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
message="This functionality requires a Pro plan or higher."
|
||||||
|
" If you are already a Pro user, please log in to access this functionality",
|
||||||
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 alert_edit_view(request, id=0, userid=0):
|
def alert_edit_view(request, id=0, userid=0):
|
||||||
@@ -2100,7 +2049,7 @@ def alert_edit_view(request, id=0, userid=0):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
res = alert_add_filters(alert, filters)
|
_ = alert_add_filters(alert, filters)
|
||||||
messages.info(request, 'Alert was changed')
|
messages.info(request, 'Alert was changed')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -2193,7 +2142,8 @@ class AlertDelete(DeleteView):
|
|||||||
|
|
||||||
|
|
||||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
message="This functionality requires a Pro plan or higher."
|
||||||
|
" If you are already a Pro user, please log in to access this functionality",
|
||||||
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 history_view(request, userid=0):
|
def history_view(request, userid=0):
|
||||||
@@ -2216,7 +2166,7 @@ def history_view(request, userid=0):
|
|||||||
activity_enddate = timezone.now()
|
activity_enddate = timezone.now()
|
||||||
activity_enddate = usertimezone.localize(
|
activity_enddate = usertimezone.localize(
|
||||||
timezone.datetime.combine(activity_enddate.date(), time_max))
|
timezone.datetime.combine(activity_enddate.date(), time_max))
|
||||||
startdate = timezone.now()-datetime.timedelta(days=14)
|
startdate = timezone.now() - datetime.timedelta(days=14)
|
||||||
activity_startdate = usertimezone.localize(
|
activity_startdate = usertimezone.localize(
|
||||||
timezone.datetime.combine(startdate.date(), time_min))
|
timezone.datetime.combine(startdate.date(), time_min))
|
||||||
sstartdate = activity_startdate.date
|
sstartdate = activity_startdate.date
|
||||||
@@ -2246,10 +2196,6 @@ def history_view(request, userid=0):
|
|||||||
privacy='visible'
|
privacy='visible'
|
||||||
).order_by("-startdatetime")
|
).order_by("-startdatetime")
|
||||||
|
|
||||||
ids = [w.id for w in g_workouts]
|
|
||||||
|
|
||||||
columns = ['hr', 'power', 'time']
|
|
||||||
|
|
||||||
tscript, tdiv = interactive_workouttype_piechart(g_workouts)
|
tscript, tdiv = interactive_workouttype_piechart(g_workouts)
|
||||||
|
|
||||||
totalmeters, totalhours, totalminutes, totalseconds = get_totals(
|
totalmeters, totalhours, totalminutes, totalseconds = get_totals(
|
||||||
@@ -2312,19 +2258,19 @@ def history_view(request, userid=0):
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
lastseven = timezone.now()-datetime.timedelta(days=7)
|
lastseven = timezone.now() - datetime.timedelta(days=7)
|
||||||
lastfourteen = timezone.now()-datetime.timedelta(days=14)
|
lastfourteen = timezone.now() - datetime.timedelta(days=14)
|
||||||
last28 = timezone.now()-datetime.timedelta(days=28)
|
last28 = timezone.now() - datetime.timedelta(days=28)
|
||||||
|
|
||||||
today = timezone.now()
|
today = timezone.now()
|
||||||
|
|
||||||
lastyear = datetime.datetime(
|
lastyear = datetime.datetime(
|
||||||
year=today.year-1, month=today.month, day=today.day)
|
year=today.year - 1, month=today.month, day=today.day)
|
||||||
|
|
||||||
firstmay = datetime.datetime(
|
firstmay = datetime.datetime(
|
||||||
year=today.year, month=5, day=1).astimezone(usertimezone)
|
year=today.year, month=5, day=1).astimezone(usertimezone)
|
||||||
if firstmay > today: # pragma: no cover
|
if firstmay > today: # pragma: no cover
|
||||||
firstmay = datetime.datetime(year=today.year-1, month=5, day=1)
|
firstmay = datetime.datetime(year=today.year - 1, month=5, day=1)
|
||||||
|
|
||||||
return render(request, 'history.html',
|
return render(request, 'history.html',
|
||||||
{
|
{
|
||||||
@@ -2361,7 +2307,7 @@ def history_view_data(request, userid=0):
|
|||||||
time_min = datetime.time(hour=0, minute=0, second=0)
|
time_min = datetime.time(hour=0, minute=0, second=0)
|
||||||
time_max = datetime.time(hour=23, minute=59, second=59)
|
time_max = datetime.time(hour=23, minute=59, second=59)
|
||||||
|
|
||||||
startdate = timezone.now()-datetime.timedelta(days=14)
|
startdate = timezone.now() - datetime.timedelta(days=14)
|
||||||
enddate = timezone.now()
|
enddate = timezone.now()
|
||||||
activity_enddate = usertimezone.localize(
|
activity_enddate = usertimezone.localize(
|
||||||
timezone.datetime.combine(enddate.date(), time_max))
|
timezone.datetime.combine(enddate.date(), time_max))
|
||||||
@@ -2491,13 +2437,13 @@ def history_view_data(request, userid=0):
|
|||||||
|
|
||||||
# interactive hr pie chart
|
# interactive hr pie chart
|
||||||
if typeselect == 'All':
|
if typeselect == 'All':
|
||||||
totalseconds = 3600*totalhours+60*totalminutes+totalseconds
|
totalseconds = 3600 * totalhours + 60 * totalminutes + totalseconds
|
||||||
totalscript, totaldiv = interactive_hr_piechart(df, r, 'All Workouts',
|
totalscript, totaldiv = interactive_hr_piechart(df, r, 'All Workouts',
|
||||||
totalseconds=totalseconds)
|
totalseconds=totalseconds)
|
||||||
else:
|
else:
|
||||||
a_workouts = g_workouts.filter(workouttype=typeselect)
|
a_workouts = g_workouts.filter(workouttype=typeselect)
|
||||||
meters, hours, minutes, seconds = get_totals(a_workouts)
|
meters, hours, minutes, seconds = get_totals(a_workouts)
|
||||||
totalseconds = 3600*hours+60*minutes+seconds
|
totalseconds = 3600 * hours + 60 * minutes + seconds
|
||||||
ddf = getsmallrowdata_db(columns, ids=[w.id for w in a_workouts])
|
ddf = getsmallrowdata_db(columns, ids=[w.id for w in a_workouts])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user