Private
Public Access
1
0

expanded boat types & classes

This commit is contained in:
Sander Roosendaal
2018-06-07 00:50:24 +02:00
parent 657ee8b467
commit 38a201e7e7
9 changed files with 128 additions and 74 deletions

View File

@@ -606,7 +606,7 @@ def get_thumbnails(request,id):
aantalcomments = len(comments)
workouttype = 'ote'
if row.workouttype in ('water','coastal'):
if row.workouttype in types.otwtypes:
workouttype = 'otw'
try:
@@ -1330,7 +1330,7 @@ def add_workout_from_runkeeperdata(user,importid,data):
times_location = times_distance
latcoord = np.zeros(len(times_distance))
loncoord = np.zeros(len(times_distance))
if workouttype in ('water','coastal'):
if workouttype in types.otwtypes:
workouttype = 'rower'
try:
@@ -1511,7 +1511,7 @@ def add_workout_from_stdata(user,importid,data):
times_location = times_distance
latcoord = np.zeros(len(times_distance))
loncoord = np.zeros(len(times_distance))
if workouttype in ('water','coastal'):
if workouttype in types.otwtypes:
workouttype = 'rower'
try:
@@ -1682,7 +1682,7 @@ def add_workout_from_underarmourdata(user,importid,data):
times_location = times_distance
latcoord = np.zeros(len(times_distance))
loncoord = np.zeros(len(times_distance))
if workouttype in ('water','coastal'):
if workouttype in types.otwtypes:
workouttype = 'rower'
try:
@@ -2886,8 +2886,8 @@ def histo_all(request,theuser=0,
enddatestring="",
options={
'includereststrokes':False,
'workouttypes':['rower','dynamic','slides'],
'waterboattype':['1x','2x','2-','4x','4-','8+']
'workouttypes':[i[0] for i in types.workouttypes],
'waterboattype':types.waterboattype
}):
if 'options' in request.session:
@@ -2899,8 +2899,8 @@ def histo_all(request,theuser=0,
workstrokesonly = not includereststrokes
checktypes = ['water','rower','dynamic','slides','skierg',
'paddle','snow','coastal','other']
# checktypes = ['water','rower','dynamic','slides','skierg',
# 'paddle','snow','coastal','other']
if deltadays>0:
@@ -2972,8 +2972,8 @@ def cum_flex_data(
request,
options={
'includereststrokes':False,
'workouttypes':['rower','dynamic','slides'],
'waterboattype':['1x','2x','2-','4x','4-','8+'],
'workouttypes':[i[0] for i in types.workouttypes],
'waterboattype':types.waterboattype,
'theuser':0,
'xparam':'spm',
'yparam1':'power',
@@ -3072,8 +3072,8 @@ def cum_flex(request,theuser=0,
enddatestring="",
options={
'includereststrokes':False,
'workouttypes':['rower','dynamic','slides'],
'waterboattype':['1x','2x','2-','4x','4-','8+']
'workouttypes':[i[0] for i in types.workouttypes],
'waterboattype':types.waterboattype
}):
if 'options' in request.session:
@@ -3082,7 +3082,7 @@ def cum_flex(request,theuser=0,
try:
workouttypes = options['workouttypes']
except KeyError:
workouttypes = ['rower','dynamic','slides']
workouttypes = [i[0] for i in types.workouttypes]
try:
includereststrokes = options['includereststrokes']
@@ -3092,13 +3092,13 @@ def cum_flex(request,theuser=0,
try:
waterboattype = options['waterboattype']
except KeyError:
waterboattype = ['1x','2x','2-','4x','4-','8+']
waterboattype = types.waterboattype
workstrokesonly = not includereststrokes
checktypes = ['water','rower','dynamic','slides','skierg',
'paddle','snow','coastal','other']
# checktypes = ['water','rower','dynamic','slides','skierg',
# 'paddle','snow','coastal','other']
if deltadays>0:
@@ -3176,7 +3176,7 @@ def cum_flex(request,theuser=0,
workstrokesonly = not includereststrokes
waterboattype = optionsform.cleaned_data['waterboattype']
workouttypes = []
for type in checktypes:
for type in types.checktypes:
if optionsform.cleaned_data[type]:
workouttypes.append(type)
@@ -3222,7 +3222,7 @@ def cum_flex(request,theuser=0,
initial['waterboattype'] = waterboattype
for wtype in checktypes:
for wtype in types.checktypes:
if wtype in workouttypes:
initial[wtype] = True
else:
@@ -3409,8 +3409,8 @@ def histo(request,theuser=0,
enddatestring="",
options={
'includereststrokes':False,
'workouttypes':['water','rower','dynamic','slides'],
'waterboattype':['1x','2x','2-','4x','4-','8+']
'workouttypes':[i[0] for i in types.workouttypes],
'waterboattype':types.waterboattype
}):
if 'options' in request.session:
@@ -3421,15 +3421,15 @@ def histo(request,theuser=0,
includereststrokes = options['includereststrokes']
waterboattype = options['waterboattype']
except KeyError:
workouttypes = ['water','rower','dynamic','slides']
waterboattype = ['1x','2x','2-','4x','4-','8+']
workouttypes = [i[0] for i in types.workouttypes]
waterboattype = types.waterboattype
includereststrokes = False
workstrokesonly = not includereststrokes
checktypes = ['water','rower','dynamic','slides','skierg',
'paddle','snow','coastal','other']
# checktypes = ['water','rower','dynamic','slides','skierg',
# 'paddle','snow','coastal','other']
if deltadays>0:
startdate = enddate-datetime.timedelta(days=int(deltadays))
@@ -3499,7 +3499,7 @@ def histo(request,theuser=0,
workstrokesonly = not includereststrokes
waterboattype = optionsform.cleaned_data['waterboattype']
workouttypes = []
for type in checktypes:
for type in types.checktypes:
if optionsform.cleaned_data[type]:
workouttypes.append(type)
@@ -3564,7 +3564,7 @@ def histo(request,theuser=0,
initial['waterboattype'] = waterboattype
for wtype in checktypes:
for wtype in types.checktypes:
if wtype in workouttypes:
initial[wtype] = True
else:
@@ -4476,7 +4476,7 @@ def workout_update_cp_view(request,id=0):
dataprep.runcpupdate(r)
if row.workouttype in ('water','coastal'):
if row.workouttype in types.otwtypes:
url = reverse(otwrankings_view)
else:
url = reverse(oterankings_view)
@@ -5297,7 +5297,7 @@ def workouts_join_select(request,
if 'waterboattype' in request.session:
waterboattype = request.session['waterboattype']
else:
waterboattype = ['1x','2x','2-','4x','4-','8+']
waterboattype = types.waterboattype
if 'modalities' in request.session:
@@ -5456,7 +5456,7 @@ def team_comparison_select(request,
if 'waterboattype' in request.session:
waterboattype = request.session['waterboattype']
else:
waterboattype = ['1x','2x','2-','4x','4-','8+']
waterboattype = types.waterboattype
if 'modalities' in request.session:
@@ -5720,7 +5720,7 @@ def user_multiflex_select(request,
if 'waterboattype' in request.session:
waterboattype = request.session['waterboattype']
else:
waterboattype = ['1x','2x','2-','4x','4-','8+']
waterboattype = types.waterboattype
if 'modalities' in request.session:
@@ -6214,7 +6214,7 @@ def user_boxplot_select(request,
options={
'includereststrokes':False,
'workouttypes':['rower','dynamic','slides'],
'waterboattype':['1x','2x','2-','4x','4-','8+']
'waterboattype':types.waterboattype
},
userid=0):
@@ -6238,9 +6238,9 @@ def user_boxplot_select(request,
workstrokesonly = not includereststrokes
checktypes = ['water','rower','dynamic','slides','skierg',
'paddle','snow','other','coastal']
waterboattype = ['1x','2x','2-','4x','4-','8+']
# checktypes = ['water','rower','dynamic','slides','skierg',
# 'paddle','snow','other','coastal']
waterboattype = types.waterboattype
if 'startdate' in request.session:
startdate = iso8601.parse_date(request.session['startdate'])
@@ -6287,7 +6287,7 @@ def user_boxplot_select(request,
if optionsform.is_valid():
workouttypes = []
waterboattype = optionsform.cleaned_data['waterboattype']
for type in checktypes:
for type in types.checktypes:
if optionsform.cleaned_data[type]:
workouttypes.append(type)
@@ -6361,7 +6361,7 @@ def user_boxplot_select(request,
initial = {}
initial['waterboattype'] = waterboattype
for wtype in checktypes:
for wtype in types.checktypes:
if wtype in workouttypes:
initial[wtype] = True
else:
@@ -7617,7 +7617,7 @@ def workout_geeky_view(request,id=0,message="",successmessage=""):
messages.error(request,message)
messages.info(request,successmessage)
if row.workouttype in ('water','coastal'):
if row.workouttype in types.otwtypes:
return render(request,
'otwgeeky.html',
{'workout':row,
@@ -7702,7 +7702,7 @@ def cumstats(request,theuser=0,
options={
'includereststrokes':False,
'workouttypes':['rower','dynamic','slides'],
'waterboattype':['1x','2x','2-','4x','4-','8+']
'waterboattype':types.waterboattype
}):
if 'options' in request.session:
@@ -7722,9 +7722,9 @@ def cumstats(request,theuser=0,
workstrokesonly = not includereststrokes
checktypes = ['water','rower','dynamic','slides','skierg',
'paddle','snow','other','coastal']
waterboattype = ['1x','2x','2-','4x','4-','8+']
# checktypes = ['water','rower','dynamic','slides','skierg',
# 'paddle','snow','other','coastal']
waterboattype = types.waterboattype
if deltadays>0:
startdate = enddate-datetime.timedelta(days=int(deltadays))
@@ -7800,7 +7800,7 @@ def cumstats(request,theuser=0,
workstrokesonly = not includereststrokes
workouttypes = []
waterboattype = optionsform.cleaned_data['waterboattype']
for type in checktypes:
for type in types.checktypes:
if optionsform.cleaned_data[type]:
workouttypes.append(type)
@@ -7952,7 +7952,7 @@ def cumstats(request,theuser=0,
initial['includereststrokes'] = includereststrokes
initial['waterboattype'] = waterboattype
for wtype in checktypes:
for wtype in types.checktypes:
if wtype in workouttypes:
initial[wtype] = True
else:
@@ -8172,7 +8172,7 @@ def workout_advanced_view(request,id=0,message="",successmessage=""):
messages.info(request,successmessage)
if row.workouttype in ('water','coastal'):
if row.workouttype in types.otwtypes:
return render(request,
'advancedotw.html',
{'workout':row,
@@ -8436,7 +8436,7 @@ def workout_workflow_view(request,id):
aantalcomments = len(comments)
workouttype = 'ote'
if row.workouttype in ('water','coastal'):
if row.workouttype in types.otwtypes:
workouttype = 'otw'
try:
@@ -8528,7 +8528,7 @@ def workout_flexchart3_view(request,*args,**kwargs):
mayedit=1
workouttype = 'ote'
if row.workouttype in ('water','coastal'):
if row.workouttype in types.otwtypes:
workouttype = 'otw'
try:
@@ -8686,7 +8686,7 @@ def workout_flexchart3_view(request,*args,**kwargs):
noylist = ["time","distance"]
axchoicesbasic.pop("cumdist")
if row.workouttype in ('water','coastal'):
if row.workouttype in types.otwtypes:
for name,d in rowingmetrics:
if d['mode'] == 'erg':
axchoicespro.pop(name)
@@ -10961,7 +10961,7 @@ def workout_summary_restore_view(request,id,message="",successmessage=""):
r.pw_tr,r.pw_an])/r.ftp
ftp = float(r.ftp)
if row.workouttype in ('water','coastal'):
if row.workouttype in types.otwtypes:
ftp = ftp*(100.-r.otwslack)/100.
rr = rrower(hrmax=r.max,hrut2=r.ut2,
@@ -11147,7 +11147,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
r.pw_tr,r.pw_an])/r.ftp
ftp = float(r.ftp)
if row.workouttype in ('water','coastal'):
if row.workouttype in types.otwtypes:
ftp = ftp*(100.-r.otwslack)/100.
rr = rrower(hrmax=r.max,hrut2=r.ut2,
@@ -11907,7 +11907,7 @@ def strokedatajson(request,id):
r.pw_tr,r.pw_an])/r.ftp
ftp = float(r.ftp)
if row.workouttype in ('water','coastal'):
if row.workouttype in types.otwtypes:
ftp = ftp*(100.-r.otwslack)/100.
rr = rrower(hrmax=r.max,hrut2=r.ut2,
@@ -13644,6 +13644,7 @@ def virtualevent_view(request,id=0):
cd = form.cleaned_data
sex = cd['sex']
boattype = cd['boattype']
boatclass = cd['boatclass']
age_min = cd['age_min']
age_max = cd['age_max']
weightcategory = cd['weightcategory']
@@ -13651,6 +13652,7 @@ def virtualevent_view(request,id=0):
results = VirtualRaceResult.objects.filter(
race=race,
workoutid__isnull=False,
boatclass__in=boatclass,
boattype__in=boattype,
sex__in=sex,
weightcategory__in=weightcategory,
@@ -13664,6 +13666,7 @@ def virtualevent_view(request,id=0):
dns = VirtualRaceResult.objects.filter(
race=race,
workoutid__isnull=True,
boatclass__in=boatclass,
boattype__in=boattype,
sex__in=sex,
weightcategory__in=weightcategory,
@@ -13752,6 +13755,7 @@ def virtualevent_addboat_view(request,id=0):
)
boattypes = [record.boattype for record in records]
boatclasses = [record.boatclass for record in records]
allowedboats = tuple([ type for type in types.boattypes if type[0] not in boattypes] )
@@ -13763,6 +13767,7 @@ def virtualevent_addboat_view(request,id=0):
cd = form.cleaned_data
teamname = cd['teamname']
boattype = cd['boattype']
boatclass = cd['boatclass']
weightcategory = cd['weightcategory']
age = cd['age']
mix = cd['mix']
@@ -13778,8 +13783,8 @@ def virtualevent_addboat_view(request,id=0):
if sex == 'not specified':
sex = 'male'
if boattype in boattypes:
messages.error(request,"You have already registered in that boat type")
if boattype in boattypes and boatclass in boatclasses:
messages.error(request,"You have already registered in that boat class/type")
url = reverse(virtualevent_view,
kwargs = {
'id': race.id
@@ -13799,6 +13804,7 @@ def virtualevent_addboat_view(request,id=0):
weightcategory=weightcategory,
duration=datetime.time(0,0),
boattype=boattype,
boatclass=boatclass,
coursecompleted=False,
sex=sex,
age=age
@@ -13828,7 +13834,7 @@ def virtualevent_addboat_view(request,id=0):
'weightcategory': r.weightcategory,
}
form = VirtualRaceResultForm(initial=initial,boattypes=allowedboats)
form = VirtualRaceResultForm(initial=initial)
return render(request,'virtualeventregister.html',
{
@@ -13864,6 +13870,7 @@ def virtualevent_register_view(request,id=0):
cd = form.cleaned_data
teamname = cd['teamname']
boattype = cd['boattype']
boatclass = cd['boatclass']
weightcategory = cd['weightcategory']
age = cd['age']
mix = cd['mix']
@@ -13889,6 +13896,7 @@ def virtualevent_register_view(request,id=0):
),
weightcategory=weightcategory,
duration=datetime.time(0,0),
boatclass=boatclass,
boattype=boattype,
coursecompleted=False,
sex=sex,