|
|
|
@@ -669,7 +669,7 @@ def addmanual_view(request,raceid=0):
|
|
|
|
if iform.is_valid(): # this works but cannot get the tests to work
|
|
|
|
if iform.is_valid(): # this works but cannot get the tests to work
|
|
|
|
f = iform.cleaned_data['file']
|
|
|
|
f = iform.cleaned_data['file']
|
|
|
|
|
|
|
|
|
|
|
|
if f is not None:
|
|
|
|
if f is not None: # pragma: no cover
|
|
|
|
filename,path_and_filename = handle_uploaded_image(f)
|
|
|
|
filename,path_and_filename = handle_uploaded_image(f)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
width, height = Image.open(path_and_filename).size
|
|
|
|
width, height = Image.open(path_and_filename).size
|
|
|
|
@@ -4377,10 +4377,10 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|
|
|
if dragchanged:
|
|
|
|
if dragchanged:
|
|
|
|
try: # pragma: no cover
|
|
|
|
try: # pragma: no cover
|
|
|
|
r.change_drag(newdragfactor)
|
|
|
|
r.change_drag(newdragfactor)
|
|
|
|
except AttributeError:
|
|
|
|
except AttributeError: # pragma: no cover
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
if r == 0:
|
|
|
|
if r == 0: # pragma: no cover
|
|
|
|
return HttpResponse("Error: CSV Data File Not Found")
|
|
|
|
return HttpResponse("Error: CSV Data File Not Found")
|
|
|
|
r.rowdatetime = startdatetime
|
|
|
|
r.rowdatetime = startdatetime
|
|
|
|
r.write_csv(row.csvfilename,gzip=True)
|
|
|
|
r.write_csv(row.csvfilename,gzip=True)
|
|
|
|
@@ -4517,12 +4517,12 @@ def workout_map_view(request,id=0):
|
|
|
|
if rowdata != 0:
|
|
|
|
if rowdata != 0:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
latitude = rowdata.df[' latitude']
|
|
|
|
latitude = rowdata.df[' latitude']
|
|
|
|
if not latitude.std():
|
|
|
|
if not latitude.std(): # pragma: no cover
|
|
|
|
hascoordinates = 0
|
|
|
|
hascoordinates = 0
|
|
|
|
except (KeyError,AttributeError):
|
|
|
|
except (KeyError,AttributeError):
|
|
|
|
hascoordinates = 0
|
|
|
|
hascoordinates = 0
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else: # pragma: no cover
|
|
|
|
hascoordinates = 0
|
|
|
|
hascoordinates = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -4761,7 +4761,7 @@ def workout_upload_api(request):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
fstr = post_data['file']
|
|
|
|
fstr = post_data['file']
|
|
|
|
nn, ext = os.path.splitext(fstr)
|
|
|
|
nn, ext = os.path.splitext(fstr)
|
|
|
|
if ext== '.gz':
|
|
|
|
if ext== '.gz': # pragma: no cover
|
|
|
|
nn, ext2 = os.path.splitext(nn)
|
|
|
|
nn, ext2 = os.path.splitext(nn)
|
|
|
|
ext = ext2+ext
|
|
|
|
ext = ext2+ext
|
|
|
|
f1 = uuid.uuid4().hex[:10]+'-'+time.strftime("%Y%m%d-%H%M%S")+ext
|
|
|
|
f1 = uuid.uuid4().hex[:10]+'-'+time.strftime("%Y%m%d-%H%M%S")+ext
|
|
|
|
@@ -4998,9 +4998,9 @@ def workout_upload_view(request,
|
|
|
|
rpe = docformoptions['rpe']
|
|
|
|
rpe = docformoptions['rpe']
|
|
|
|
try: # pragma: no cover
|
|
|
|
try: # pragma: no cover
|
|
|
|
rpe = int(rpe)
|
|
|
|
rpe = int(rpe)
|
|
|
|
except ValueError:
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
rpe = 0
|
|
|
|
rpe = 0
|
|
|
|
if not rpe:
|
|
|
|
if not rpe: # pragma: no cover
|
|
|
|
rpe = -1
|
|
|
|
rpe = -1
|
|
|
|
except KeyError:
|
|
|
|
except KeyError:
|
|
|
|
rpe = -1
|
|
|
|
rpe = -1
|
|
|
|
@@ -5139,15 +5139,15 @@ def workout_upload_view(request,
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
if not id:
|
|
|
|
if not id: # pragma: no cover
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.error(request,message)
|
|
|
|
url = reverse('workout_upload_view')
|
|
|
|
url = reverse('workout_upload_view')
|
|
|
|
if is_ajax:
|
|
|
|
if is_ajax: # pragma: no cover
|
|
|
|
return JSONResponse({'result':0,'url':url})
|
|
|
|
return JSONResponse({'result':0,'url':url})
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|
elif id == -1:
|
|
|
|
elif id == -1: # pragma: no cover
|
|
|
|
message = 'The zip archive will be processed in the background. The files in the archive will only be uploaded without the extra actions. You will receive email when the workouts are ready.'
|
|
|
|
message = 'The zip archive will be processed in the background. The files in the archive will only be uploaded without the extra actions. You will receive email when the workouts are ready.'
|
|
|
|
messages.info(request,message)
|
|
|
|
messages.info(request,message)
|
|
|
|
url = reverse('workout_upload_view')
|
|
|
|
url = reverse('workout_upload_view')
|
|
|
|
@@ -5157,7 +5157,7 @@ def workout_upload_view(request,
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if message:
|
|
|
|
if message: # pragma: no cover
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
|
|
w = Workout.objects.get(id=id)
|
|
|
|
w = Workout.objects.get(id=id)
|
|
|
|
@@ -5167,14 +5167,14 @@ def workout_upload_view(request,
|
|
|
|
'id':encoder.encode_hex(w.id),
|
|
|
|
'id':encoder.encode_hex(w.id),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if is_ajax:
|
|
|
|
if is_ajax: # pragma: no cover
|
|
|
|
response = {'result': 1,'url':url}
|
|
|
|
response = {'result': 1,'url':url}
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r = getrower(request.user)
|
|
|
|
r = getrower(request.user)
|
|
|
|
if (make_plot):
|
|
|
|
if (make_plot): # pragma: no cover
|
|
|
|
res,jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
|
|
|
|
res,jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
|
|
|
|
if res == 0:
|
|
|
|
if res == 0:
|
|
|
|
messages.error(request,jobid)
|
|
|
|
messages.error(request,jobid)
|
|
|
|
@@ -5188,7 +5188,7 @@ def workout_upload_view(request,
|
|
|
|
res, jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
|
|
|
|
res, jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
|
|
|
|
|
|
|
|
|
|
|
|
# upload to C2
|
|
|
|
# upload to C2
|
|
|
|
if (upload_to_c2):
|
|
|
|
if (upload_to_c2): # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
message,id = c2stuff.workout_c2_upload(request.user,w)
|
|
|
|
message,id = c2stuff.workout_c2_upload(request.user,w)
|
|
|
|
except NoTokenError:
|
|
|
|
except NoTokenError:
|
|
|
|
@@ -5199,7 +5199,7 @@ def workout_upload_view(request,
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
|
|
if (upload_to_strava):
|
|
|
|
if (upload_to_strava): # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
message,id = stravastuff.workout_strava_upload(
|
|
|
|
message,id = stravastuff.workout_strava_upload(
|
|
|
|
request.user,w,
|
|
|
|
request.user,w,
|
|
|
|
@@ -5212,7 +5212,7 @@ def workout_upload_view(request,
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
|
|
if (upload_to_st):
|
|
|
|
if (upload_to_st): # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
message,id = sporttracksstuff.workout_sporttracks_upload(
|
|
|
|
message,id = sporttracksstuff.workout_sporttracks_upload(
|
|
|
|
request.user,w
|
|
|
|
request.user,w
|
|
|
|
@@ -5225,7 +5225,7 @@ def workout_upload_view(request,
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
|
|
if (upload_to_rk):
|
|
|
|
if (upload_to_rk): # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
message,id = runkeeperstuff.workout_runkeeper_upload(
|
|
|
|
message,id = runkeeperstuff.workout_runkeeper_upload(
|
|
|
|
request.user,w
|
|
|
|
request.user,w
|
|
|
|
@@ -5240,7 +5240,7 @@ def workout_upload_view(request,
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (upload_to_ua):
|
|
|
|
if (upload_to_ua): # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
message,id = underarmourstuff.workout_ua_upload(
|
|
|
|
message,id = underarmourstuff.workout_ua_upload(
|
|
|
|
request.user,w
|
|
|
|
request.user,w
|
|
|
|
@@ -5255,7 +5255,7 @@ def workout_upload_view(request,
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (upload_to_tp):
|
|
|
|
if (upload_to_tp): # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
message,id = tpstuff.workout_tp_upload(
|
|
|
|
message,id = tpstuff.workout_tp_upload(
|
|
|
|
request.user,w
|
|
|
|
request.user,w
|
|
|
|
@@ -5269,7 +5269,7 @@ def workout_upload_view(request,
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
|
|
if int(registrationid) < 0:
|
|
|
|
if int(registrationid) < 0: # pragma: no cover
|
|
|
|
race = VirtualRace.objects.get(id=-int(registrationid))
|
|
|
|
race = VirtualRace.objects.get(id=-int(registrationid))
|
|
|
|
if race.sessiontype == 'race':
|
|
|
|
if race.sessiontype == 'race':
|
|
|
|
result,comments,errors,jobid = add_workout_race(
|
|
|
|
result,comments,errors,jobid = add_workout_race(
|
|
|
|
@@ -5309,7 +5309,7 @@ def workout_upload_view(request,
|
|
|
|
for er in errors:
|
|
|
|
for er in errors:
|
|
|
|
messages.error(request,er)
|
|
|
|
messages.error(request,er)
|
|
|
|
|
|
|
|
|
|
|
|
if int(registrationid)>0:
|
|
|
|
if int(registrationid)>0: # pragma: no cover
|
|
|
|
races = VirtualRace.objects.filter(
|
|
|
|
races = VirtualRace.objects.filter(
|
|
|
|
registration_closure__gt=timezone.now()
|
|
|
|
registration_closure__gt=timezone.now()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
@@ -5330,7 +5330,7 @@ def workout_upload_view(request,
|
|
|
|
userid=r.id,
|
|
|
|
userid=r.id,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if int(registrationid) in [r.id for r in registrations]:
|
|
|
|
if int(registrationid) in [r.id for r in registrations]: # pragma: no cover
|
|
|
|
# indoor race
|
|
|
|
# indoor race
|
|
|
|
registrations = registrations.filter(id=registrationid)
|
|
|
|
registrations = registrations.filter(id=registrationid)
|
|
|
|
if registrations:
|
|
|
|
if registrations:
|
|
|
|
@@ -5355,7 +5355,7 @@ def workout_upload_view(request,
|
|
|
|
messages.error(request,er)
|
|
|
|
messages.error(request,er)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if int(registrationid) in [r.id for r in registrations2]:
|
|
|
|
if int(registrationid) in [r.id for r in registrations2]: # pragma: no cover
|
|
|
|
# race
|
|
|
|
# race
|
|
|
|
registrations = registrations2.filter(id=registrationid)
|
|
|
|
registrations = registrations2.filter(id=registrationid)
|
|
|
|
if registrations:
|
|
|
|
if registrations:
|
|
|
|
@@ -5380,7 +5380,7 @@ def workout_upload_view(request,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if registrationid != 0:
|
|
|
|
if registrationid != 0: # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
url = reverse('virtualevent_view',
|
|
|
|
url = reverse('virtualevent_view',
|
|
|
|
kwargs = {
|
|
|
|
kwargs = {
|
|
|
|
@@ -5392,23 +5392,23 @@ def workout_upload_view(request,
|
|
|
|
kwargs = {
|
|
|
|
kwargs = {
|
|
|
|
'id':encoder.encode_hex(w.id),
|
|
|
|
'id':encoder.encode_hex(w.id),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
else:
|
|
|
|
else: # pragma: no cover
|
|
|
|
url = reverse(landingpage)
|
|
|
|
url = reverse(landingpage)
|
|
|
|
elif landingpage != 'workout_upload_view':
|
|
|
|
elif landingpage != 'workout_upload_view': # pragma: no cover
|
|
|
|
url = reverse(landingpage,
|
|
|
|
url = reverse(landingpage,
|
|
|
|
kwargs = {
|
|
|
|
kwargs = {
|
|
|
|
'id':encoder.encode_hex(w.id),
|
|
|
|
'id':encoder.encode_hex(w.id),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else: # pragma: no cover
|
|
|
|
url = reverse(landingpage)
|
|
|
|
url = reverse(landingpage)
|
|
|
|
|
|
|
|
|
|
|
|
if is_ajax:
|
|
|
|
if is_ajax: # pragma: no cover
|
|
|
|
response = {'result':1,'url':url}
|
|
|
|
response = {'result':1,'url':url}
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if not is_ajax:
|
|
|
|
if not is_ajax: # pragma: no cover
|
|
|
|
response = render(request,
|
|
|
|
response = render(request,
|
|
|
|
'document_form.html',
|
|
|
|
'document_form.html',
|
|
|
|
{'form':form,
|
|
|
|
{'form':form,
|
|
|
|
@@ -5417,28 +5417,28 @@ def workout_upload_view(request,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if is_ajax:
|
|
|
|
if is_ajax: # pragma: no cover
|
|
|
|
return JSONResponse(response)
|
|
|
|
return JSONResponse(response)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if not is_ajax:
|
|
|
|
if not is_ajax:
|
|
|
|
if r.c2_auto_export and ispromember(r.user):
|
|
|
|
if r.c2_auto_export and ispromember(r.user): # pragma: no cover
|
|
|
|
uploadoptions['upload_to_C2'] = True
|
|
|
|
uploadoptions['upload_to_C2'] = True
|
|
|
|
|
|
|
|
|
|
|
|
if r.strava_auto_export and ispromember(r.user):
|
|
|
|
if r.strava_auto_export and ispromember(r.user): # pragma: no cover
|
|
|
|
uploadoptions['upload_to_Strava'] = True
|
|
|
|
uploadoptions['upload_to_Strava'] = True
|
|
|
|
|
|
|
|
|
|
|
|
if r.sporttracks_auto_export and ispromember(r.user):
|
|
|
|
if r.sporttracks_auto_export and ispromember(r.user): # pragma: no cover
|
|
|
|
uploadoptions['upload_to_SportTracks'] = True
|
|
|
|
uploadoptions['upload_to_SportTracks'] = True
|
|
|
|
|
|
|
|
|
|
|
|
if r.runkeeper_auto_export and ispromember(r.user):
|
|
|
|
if r.runkeeper_auto_export and ispromember(r.user): # pragma: no cover
|
|
|
|
uploadoptions['upload_to_RunKeeper'] = True
|
|
|
|
uploadoptions['upload_to_RunKeeper'] = True
|
|
|
|
|
|
|
|
|
|
|
|
if r.trainingpeaks_auto_export and ispromember(r.user):
|
|
|
|
if r.trainingpeaks_auto_export and ispromember(r.user): # pragma: no cover
|
|
|
|
uploadoptions['upload_to_TrainingPeaks'] = True
|
|
|
|
uploadoptions['upload_to_TrainingPeaks'] = True
|
|
|
|
|
|
|
|
|
|
|
|
if r.mapmyfitness_auto_export and ispromember(r.user):
|
|
|
|
if r.mapmyfitness_auto_export and ispromember(r.user): # pragma: no cover
|
|
|
|
uploadoptions['upload_to_MapMyFitness'] = True
|
|
|
|
uploadoptions['upload_to_MapMyFitness'] = True
|
|
|
|
|
|
|
|
|
|
|
|
form = DocumentsForm(initial=docformoptions)
|
|
|
|
form = DocumentsForm(initial=docformoptions)
|
|
|
|
@@ -5451,7 +5451,7 @@ def workout_upload_view(request,
|
|
|
|
'teams':get_my_teams(request.user),
|
|
|
|
'teams':get_my_teams(request.user),
|
|
|
|
'optionsform': optionsform,
|
|
|
|
'optionsform': optionsform,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
else:
|
|
|
|
else: # pragma: no cover
|
|
|
|
return {'result':0}
|
|
|
|
return {'result':0}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -5499,7 +5499,7 @@ def team_workout_upload_view(request,message="",
|
|
|
|
).exclude(
|
|
|
|
).exclude(
|
|
|
|
rowerplan='freecoach'
|
|
|
|
rowerplan='freecoach'
|
|
|
|
).distinct()
|
|
|
|
).distinct()
|
|
|
|
if r.rowerplan == 'freecoach':
|
|
|
|
if r.rowerplan == 'freecoach': # pragma: no cover
|
|
|
|
rowers = rowers.exclude(rowerplan='basic')
|
|
|
|
rowers = rowers.exclude(rowerplan='basic')
|
|
|
|
|
|
|
|
|
|
|
|
rowerform.fields['user'].queryset = User.objects.filter(rower__in=rowers).distinct()
|
|
|
|
rowerform.fields['user'].queryset = User.objects.filter(rower__in=rowers).distinct()
|
|
|
|
@@ -5508,7 +5508,7 @@ def team_workout_upload_view(request,message="",
|
|
|
|
f = request.FILES.get('file',False)
|
|
|
|
f = request.FILES.get('file',False)
|
|
|
|
if f:
|
|
|
|
if f:
|
|
|
|
res = handle_uploaded_file(f)
|
|
|
|
res = handle_uploaded_file(f)
|
|
|
|
else:
|
|
|
|
else: # pragma: no cover
|
|
|
|
messages.error(request,'No file attached')
|
|
|
|
messages.error(request,'No file attached')
|
|
|
|
response = render(request,
|
|
|
|
response = render(request,
|
|
|
|
'team_document_form.html',
|
|
|
|
'team_document_form.html',
|
|
|
|
@@ -5526,7 +5526,7 @@ def team_workout_upload_view(request,message="",
|
|
|
|
if rowerform.is_valid():
|
|
|
|
if rowerform.is_valid():
|
|
|
|
u = rowerform.cleaned_data['user']
|
|
|
|
u = rowerform.cleaned_data['user']
|
|
|
|
r = getrower(u)
|
|
|
|
r = getrower(u)
|
|
|
|
if not can_add_workout_member(request.user,r):
|
|
|
|
if not can_add_workout_member(request.user,r): # pragma: no cover
|
|
|
|
message = 'Please select a rower'
|
|
|
|
message = 'Please select a rower'
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.info(request,successmessage)
|
|
|
|
messages.info(request,successmessage)
|
|
|
|
@@ -5571,7 +5571,7 @@ def team_workout_upload_view(request,message="",
|
|
|
|
title = t,
|
|
|
|
title = t,
|
|
|
|
notes=''
|
|
|
|
notes=''
|
|
|
|
)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
else: # pragma: no cover
|
|
|
|
job = myqueue(
|
|
|
|
job = myqueue(
|
|
|
|
queuehigh,
|
|
|
|
queuehigh,
|
|
|
|
handle_zip_file,
|
|
|
|
handle_zip_file,
|
|
|
|
@@ -5592,12 +5592,12 @@ def team_workout_upload_view(request,message="",
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not id:
|
|
|
|
if not id: # pragma: no cover
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.error(request,message)
|
|
|
|
url = reverse('team_workout_upload_view')
|
|
|
|
url = reverse('team_workout_upload_view')
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|
elif id == -1:
|
|
|
|
elif id == -1: # pragma: no cover
|
|
|
|
message = 'The zip archive will be processed in the background. The files in the archive will only be uploaded without the extra actions. You will receive email when the workouts are ready.'
|
|
|
|
message = 'The zip archive will be processed in the background. The files in the archive will only be uploaded without the extra actions. You will receive email when the workouts are ready.'
|
|
|
|
messages.info(request,message)
|
|
|
|
messages.info(request,message)
|
|
|
|
url = reverse('team_workout_upload_view')
|
|
|
|
url = reverse('team_workout_upload_view')
|
|
|
|
@@ -5614,7 +5614,7 @@ def team_workout_upload_view(request,message="",
|
|
|
|
w = Workout.objects.get(id=id)
|
|
|
|
w = Workout.objects.get(id=id)
|
|
|
|
|
|
|
|
|
|
|
|
r = getrower(request.user)
|
|
|
|
r = getrower(request.user)
|
|
|
|
if (make_plot):
|
|
|
|
if (make_plot): # pragma: no cover
|
|
|
|
id,jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
|
|
|
|
id,jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
|
|
|
|
elif r.staticchartonupload:
|
|
|
|
elif r.staticchartonupload:
|
|
|
|
plottype = r.staticchartonupload
|
|
|
|
plottype = r.staticchartonupload
|
|
|
|
@@ -5647,7 +5647,7 @@ def team_workout_upload_view(request,message="",
|
|
|
|
).exclude(
|
|
|
|
).exclude(
|
|
|
|
rowerplan='freecoach'
|
|
|
|
rowerplan='freecoach'
|
|
|
|
).distinct()
|
|
|
|
).distinct()
|
|
|
|
if r.rowerplan == 'freecoach':
|
|
|
|
if r.rowerplan == 'freecoach': # pragma: no cover
|
|
|
|
rowers = rowers.exclude(rowerplan='basic')
|
|
|
|
rowers = rowers.exclude(rowerplan='basic')
|
|
|
|
|
|
|
|
|
|
|
|
rowerform.fields['user'].queryset = User.objects.filter(rower__in=rowers).distinct()
|
|
|
|
rowerform.fields['user'].queryset = User.objects.filter(rower__in=rowers).distinct()
|
|
|
|
@@ -5673,7 +5673,7 @@ def list_videos(request,userid=0):
|
|
|
|
r = getrequestrower(request,userid=userid)
|
|
|
|
r = getrequestrower(request,userid=userid)
|
|
|
|
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")
|
|
|
|
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")
|
|
|
|
query = request.GET.get('q')
|
|
|
|
query = request.GET.get('q')
|
|
|
|
if query:
|
|
|
|
if query: # pragma: no cover
|
|
|
|
query_list = query.split()
|
|
|
|
query_list = query.split()
|
|
|
|
if query:
|
|
|
|
if query:
|
|
|
|
query_list = query.split()
|
|
|
|
query_list = query.split()
|
|
|
|
@@ -5695,7 +5695,7 @@ def list_videos(request,userid=0):
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
g = paginator.page(page)
|
|
|
|
g = paginator.page(page)
|
|
|
|
except EmptyPage:
|
|
|
|
except EmptyPage: # pragma: no cover
|
|
|
|
g = paginator.page(paginator.num_pages)
|
|
|
|
g = paginator.page(paginator.num_pages)
|
|
|
|
|
|
|
|
|
|
|
|
return render(request, 'list_videos.html',
|
|
|
|
return render(request, 'list_videos.html',
|
|
|
|
@@ -5712,7 +5712,7 @@ def graphs_view(request,userid=0):
|
|
|
|
r = getrequestrower(request,userid=userid)
|
|
|
|
r = getrequestrower(request,userid=userid)
|
|
|
|
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")
|
|
|
|
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")
|
|
|
|
query = request.GET.get('q')
|
|
|
|
query = request.GET.get('q')
|
|
|
|
if query:
|
|
|
|
if query: # pragma: no cover
|
|
|
|
query_list = query.split()
|
|
|
|
query_list = query.split()
|
|
|
|
workouts = workouts.filter(
|
|
|
|
workouts = workouts.filter(
|
|
|
|
reduce(operator.and_,
|
|
|
|
reduce(operator.and_,
|
|
|
|
@@ -5734,7 +5734,7 @@ def graphs_view(request,userid=0):
|
|
|
|
g = paginator.page(page)
|
|
|
|
g = paginator.page(page)
|
|
|
|
except PageNotAnInteger:
|
|
|
|
except PageNotAnInteger:
|
|
|
|
g = paginator.page(1)
|
|
|
|
g = paginator.page(1)
|
|
|
|
except EmptyPage:
|
|
|
|
except EmptyPage: # pragma: no cover
|
|
|
|
g = paginator.page(paginator.num_pages)
|
|
|
|
g = paginator.page(paginator.num_pages)
|
|
|
|
|
|
|
|
|
|
|
|
return render(request, 'list_graphs.html',
|
|
|
|
return render(request, 'list_graphs.html',
|
|
|
|
@@ -5751,7 +5751,7 @@ def graphs_view(request,userid=0):
|
|
|
|
def graph_show_view(request,id):
|
|
|
|
def graph_show_view(request,id):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
g = GraphImage.objects.get(id=id)
|
|
|
|
g = GraphImage.objects.get(id=id)
|
|
|
|
try:
|
|
|
|
try: # pragma: no cover
|
|
|
|
width,height = Image.open(g.filename).size
|
|
|
|
width,height = Image.open(g.filename).size
|
|
|
|
g.width = width
|
|
|
|
g.width = width
|
|
|
|
g.height = height
|
|
|
|
g.height = height
|
|
|
|
@@ -5787,9 +5787,9 @@ def graph_show_view(request,id):
|
|
|
|
'active':'nav-workouts',
|
|
|
|
'active':'nav-workouts',
|
|
|
|
'rower':r,})
|
|
|
|
'rower':r,})
|
|
|
|
|
|
|
|
|
|
|
|
except GraphImage.DoesNotExist:
|
|
|
|
except GraphImage.DoesNotExist: # pragma: no cover
|
|
|
|
raise Http404("This graph doesn't exist")
|
|
|
|
raise Http404("This graph doesn't exist")
|
|
|
|
except Workout.DoesNotExist:
|
|
|
|
except Workout.DoesNotExist: # pragma: no cover
|
|
|
|
raise Http404("This workout doesn't exist")
|
|
|
|
raise Http404("This workout doesn't exist")
|
|
|
|
|
|
|
|
|
|
|
|
# Restore original stroke data and summary
|
|
|
|
# Restore original stroke data and summary
|
|
|
|
@@ -5888,13 +5888,13 @@ def workout_split_view(request,id=0):
|
|
|
|
messages.error(request,"Something went wrong in Split")
|
|
|
|
messages.error(request,"Something went wrong in Split")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if request.user == r:
|
|
|
|
if request.user == r: # pragma: no cover
|
|
|
|
url = reverse('workouts_view')
|
|
|
|
url = reverse('workouts_view')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
mgrids = [team.id for team in Team.objects.filter(manager=request.user)]
|
|
|
|
mgrids = [team.id for team in Team.objects.filter(manager=request.user)]
|
|
|
|
rwrids = [team.id for team in r.team.all()]
|
|
|
|
rwrids = [team.id for team in r.team.all()]
|
|
|
|
teamids = list(set(mgrids) & set(rwrids))
|
|
|
|
teamids = list(set(mgrids) & set(rwrids))
|
|
|
|
if len(teamids) > 0:
|
|
|
|
if len(teamids) > 0: # pragma: no cover
|
|
|
|
teamid = teamids[0]
|
|
|
|
teamid = teamids[0]
|
|
|
|
|
|
|
|
|
|
|
|
url = reverse('workouts_view',
|
|
|
|
url = reverse('workouts_view',
|
|
|
|
@@ -5907,9 +5907,9 @@ def workout_split_view(request,id=0):
|
|
|
|
|
|
|
|
|
|
|
|
rowname = row.name
|
|
|
|
rowname = row.name
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if isinstance(rowname,unicode):
|
|
|
|
if isinstance(rowname,unicode): # pragma: no cover
|
|
|
|
rowname = rowname.encode('utf8')
|
|
|
|
rowname = rowname.encode('utf8')
|
|
|
|
elif isinstance(rowname, str):
|
|
|
|
elif isinstance(rowname, str): # pragma: no cover
|
|
|
|
rowname = rowname.decode('utf8')
|
|
|
|
rowname = rowname.decode('utf8')
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
@@ -5947,7 +5947,7 @@ def workout_fusion_view(request,id1=0,id2=1):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
id1 = encoder.decode_hex(id1)
|
|
|
|
id1 = encoder.decode_hex(id1)
|
|
|
|
id2 = encoder.decode_hex(id2)
|
|
|
|
id2 = encoder.decode_hex(id2)
|
|
|
|
except:
|
|
|
|
except: # pragma: no cover
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
r = getrower(request.user)
|
|
|
|
r = getrower(request.user)
|
|
|
|
@@ -5957,9 +5957,9 @@ def workout_fusion_view(request,id1=0,id2=1):
|
|
|
|
w2 = Workout.objects.get(id=id2)
|
|
|
|
w2 = Workout.objects.get(id=id2)
|
|
|
|
r = w1.user
|
|
|
|
r = w1.user
|
|
|
|
if (is_workout_user(request.user,w1)==False) or \
|
|
|
|
if (is_workout_user(request.user,w1)==False) or \
|
|
|
|
(is_workout_user(request.user,w2)==False):
|
|
|
|
(is_workout_user(request.user,w2)==False): # pragma: no cover
|
|
|
|
raise PermissionDenied("You are not allowed to use these workouts")
|
|
|
|
raise PermissionDenied("You are not allowed to use these workouts")
|
|
|
|
except Workout.DoesNotExist:
|
|
|
|
except Workout.DoesNotExist: # pragma: no cover
|
|
|
|
raise Http404("One of the workouts doesn't exist")
|
|
|
|
raise Http404("One of the workouts doesn't exist")
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|
@@ -5969,7 +5969,7 @@ def workout_fusion_view(request,id1=0,id2=1):
|
|
|
|
columns = cd['columns']
|
|
|
|
columns = cd['columns']
|
|
|
|
timeoffset = cd['offset']
|
|
|
|
timeoffset = cd['offset']
|
|
|
|
posneg = cd['posneg']
|
|
|
|
posneg = cd['posneg']
|
|
|
|
if posneg == 'neg':
|
|
|
|
if posneg == 'neg': # pragma: no cover
|
|
|
|
timeoffset = -timeoffset
|
|
|
|
timeoffset = -timeoffset
|
|
|
|
|
|
|
|
|
|
|
|
# Create DataFrame
|
|
|
|
# Create DataFrame
|
|
|
|
@@ -5980,7 +5980,7 @@ def workout_fusion_view(request,id1=0,id2=1):
|
|
|
|
title='Fused data',
|
|
|
|
title='Fused data',
|
|
|
|
parent=w1,
|
|
|
|
parent=w1,
|
|
|
|
forceunit=forceunit)
|
|
|
|
forceunit=forceunit)
|
|
|
|
if message != None:
|
|
|
|
if message != None: # pragma: no cover
|
|
|
|
messages.error(request,message)
|
|
|
|
messages.error(request,message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
successmessage = 'Data fused'
|
|
|
|
successmessage = 'Data fused'
|
|
|
|
@@ -6124,12 +6124,12 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
normw = int(normw)
|
|
|
|
normw = int(normw)
|
|
|
|
except ValueError:
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
normw = 100
|
|
|
|
normw = 100
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
normp = int(normp)
|
|
|
|
normp = int(normp)
|
|
|
|
except ValueError:
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
normp = 100
|
|
|
|
normp = 100
|
|
|
|
|
|
|
|
|
|
|
|
data = {
|
|
|
|
data = {
|
|
|
|
@@ -6160,7 +6160,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
s = cd["intervalstring"]
|
|
|
|
s = cd["intervalstring"]
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
rowdata.updateinterval_string(s)
|
|
|
|
rowdata.updateinterval_string(s)
|
|
|
|
except:
|
|
|
|
except: # pragma: no cover
|
|
|
|
messages.error(request,'Parsing error')
|
|
|
|
messages.error(request,'Parsing error')
|
|
|
|
intervalstats = rowdata.allstats()
|
|
|
|
intervalstats = rowdata.allstats()
|
|
|
|
itime,idist,itype = rowdata.intervalstats_values()
|
|
|
|
itime,idist,itype = rowdata.intervalstats_values()
|
|
|
|
@@ -6170,51 +6170,34 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
|
|
|
|
|
|
|
# we are saving the results obtained from the split by power/pace interpreter
|
|
|
|
# we are saving the results obtained from the split by power/pace interpreter
|
|
|
|
elif request.method == 'POST' and "savepowerpaceform" in request.POST:
|
|
|
|
elif request.method == 'POST' and "savepowerpaceform" in request.POST:
|
|
|
|
try:
|
|
|
|
powerorpace = request.POST.get('powerorpace','pace')
|
|
|
|
powerorpace = request.POST['powerorpace']
|
|
|
|
value_pace = request.POST.get('value_pace',avpace)
|
|
|
|
except:
|
|
|
|
value_power = request.POST.get('value_power',int(normp))
|
|
|
|
powerorpace = 'pace'
|
|
|
|
value_work = request.POST.get('value_work',int(normw))
|
|
|
|
try:
|
|
|
|
value_spm = request.POST.get('value_spm',int(normspm))
|
|
|
|
value_pace = request.POST['value_pace']
|
|
|
|
activeminutesmin = request.POST.get('activeminutesmin',0)
|
|
|
|
except:
|
|
|
|
|
|
|
|
value_pace = avpace
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
value_power = request.POST['value_power']
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
value_power = int(normp)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
value_work = request.POST['value_work']
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
value_work = int(normw)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
value_spm = request.POST['value_spm']
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
value_spm = int(normspm)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
activeminutesmin = request.POST['activeminutesmin']
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
activeminutesmin = 0
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
activeminutesmax = request.POST['activeminutesmax']
|
|
|
|
activeminutesmax = request.POST['activeminutesmax']
|
|
|
|
except:
|
|
|
|
except: # pragma: no cover
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
activesecondsmin = 60.*float(activeminutesmin)
|
|
|
|
activesecondsmin = 60.*float(activeminutesmin)
|
|
|
|
activesecondsmax = 60.*float(activeminutesmax)
|
|
|
|
activesecondsmax = 60.*float(activeminutesmax)
|
|
|
|
except ValueError:
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
activesecondsmin = 0
|
|
|
|
activesecondsmin = 0
|
|
|
|
activeminutesmin = 0
|
|
|
|
activeminutesmin = 0
|
|
|
|
activeminutesmax = maxminutes
|
|
|
|
activeminutesmax = maxminutes
|
|
|
|
activesecondsmax = rowdata.duration
|
|
|
|
activesecondsmax = rowdata.duration
|
|
|
|
|
|
|
|
|
|
|
|
if abs(rowdata.duration-activesecondsmax) < 60.:
|
|
|
|
if abs(rowdata.duration-activesecondsmax) < 60.: # pragma: no cover
|
|
|
|
activesecondsmax = rowdata.duration
|
|
|
|
activesecondsmax = rowdata.duration
|
|
|
|
if powerorpace == 'power':
|
|
|
|
if powerorpace == 'power':
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
power = int(value_power)
|
|
|
|
power = int(value_power)
|
|
|
|
except ValueError:
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
int(normp)
|
|
|
|
int(normp)
|
|
|
|
elif powerorpace == 'pace':
|
|
|
|
elif powerorpace == 'pace': # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
pace_secs = float(value_pace)
|
|
|
|
pace_secs = float(value_pace)
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
@@ -6222,12 +6205,12 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
pace_secs = float(value_pace.replace(',','.'))
|
|
|
|
pace_secs = float(value_pace.replace(',','.'))
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
pace_secs = int(500./normv)
|
|
|
|
pace_secs = int(500./normv)
|
|
|
|
elif powerorpace == 'work':
|
|
|
|
elif powerorpace == 'work': # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
work = int(value_work)
|
|
|
|
work = int(value_work)
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
work = int(normw)
|
|
|
|
work = int(normw)
|
|
|
|
elif powerorpace == 'spm':
|
|
|
|
elif powerorpace == 'spm': # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
spm = int(value_spm)
|
|
|
|
spm = int(value_spm)
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
@@ -6240,9 +6223,9 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
debug=False,smoothwindow=15.,
|
|
|
|
debug=False,smoothwindow=15.,
|
|
|
|
activewindow=[activesecondsmin,activesecondsmax],
|
|
|
|
activewindow=[activesecondsmin,activesecondsmax],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except:
|
|
|
|
except: # pragma: no cover
|
|
|
|
messages.error(request,'Error updating power')
|
|
|
|
messages.error(request,'Error updating power')
|
|
|
|
elif powerorpace == 'pace':
|
|
|
|
elif powerorpace == 'pace': # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
velo = 500./pace_secs
|
|
|
|
velo = 500./pace_secs
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
@@ -6252,7 +6235,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
messages.error(request,'Error updating pace')
|
|
|
|
messages.error(request,'Error updating pace')
|
|
|
|
elif powerorpace == 'work':
|
|
|
|
elif powerorpace == 'work': # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
'driveenergy',work,mode='larger',
|
|
|
|
'driveenergy',work,mode='larger',
|
|
|
|
@@ -6261,7 +6244,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
messages.error(request,'Error updating Work per Stroke')
|
|
|
|
messages.error(request,'Error updating Work per Stroke')
|
|
|
|
elif powerorpace == 'spm':
|
|
|
|
elif powerorpace == 'spm': # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
' Cadence (stokes/min)',spm,mode='larger',
|
|
|
|
' Cadence (stokes/min)',spm,mode='larger',
|
|
|
|
@@ -6307,7 +6290,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
s = request.POST["savestringform"]
|
|
|
|
s = request.POST["savestringform"]
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
rowdata.updateinterval_string(s)
|
|
|
|
rowdata.updateinterval_string(s)
|
|
|
|
except (ParseException,err):
|
|
|
|
except (ParseException,err): # pragma: no cover
|
|
|
|
messages.error(request,'Parsing error in column '+str(err.col))
|
|
|
|
messages.error(request,'Parsing error in column '+str(err.col))
|
|
|
|
|
|
|
|
|
|
|
|
intervalstats = rowdata.allstats()
|
|
|
|
intervalstats = rowdata.allstats()
|
|
|
|
@@ -6321,7 +6304,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
n = row.notes,
|
|
|
|
n = row.notes,
|
|
|
|
s = s
|
|
|
|
s = s
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except TypeError:
|
|
|
|
except TypeError: # pragma: no cover
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
row.save()
|
|
|
|
row.save()
|
|
|
|
@@ -6355,11 +6338,11 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
activeminutesmax = cd['activeminutesmax']
|
|
|
|
activeminutesmax = cd['activeminutesmax']
|
|
|
|
activesecondsmin = 60.*activeminutesmin
|
|
|
|
activesecondsmin = 60.*activeminutesmin
|
|
|
|
activesecondsmax = 60.*activeminutesmax
|
|
|
|
activesecondsmax = 60.*activeminutesmax
|
|
|
|
if abs(rowdata.duration-activesecondsmax) < 60.:
|
|
|
|
if abs(rowdata.duration-activesecondsmax) < 60.: # pragma: no cover
|
|
|
|
activesecondsmax = rowdata.duration
|
|
|
|
activesecondsmax = rowdata.duration
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
pace_secs = pace.seconds+pace.microseconds/1.0e6
|
|
|
|
pace_secs = pace.seconds+pace.microseconds/1.0e6
|
|
|
|
except AttributeError:
|
|
|
|
except AttributeError: # pragma: no cover
|
|
|
|
pace_secs = 120.
|
|
|
|
pace_secs = 120.
|
|
|
|
|
|
|
|
|
|
|
|
if powerorpace == 'power' and power is not None:
|
|
|
|
if powerorpace == 'power' and power is not None:
|
|
|
|
@@ -6368,7 +6351,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
activewindow=[activesecondsmin,activesecondsmax],
|
|
|
|
activewindow=[activesecondsmin,activesecondsmax],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
elif powerorpace == 'pace':
|
|
|
|
elif powerorpace == 'pace': # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
velo = 500./pace_secs
|
|
|
|
velo = 500./pace_secs
|
|
|
|
rowdata.updateinterval_metric(' AverageBoatSpeed (m/s)',velo,mode='larger',
|
|
|
|
rowdata.updateinterval_metric(' AverageBoatSpeed (m/s)',velo,mode='larger',
|
|
|
|
@@ -6377,7 +6360,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
messages.error(request,'Error updating pace')
|
|
|
|
messages.error(request,'Error updating pace')
|
|
|
|
elif powerorpace == 'work':
|
|
|
|
elif powerorpace == 'work': # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
'driveenergy',work,mode='larger',
|
|
|
|
'driveenergy',work,mode='larger',
|
|
|
|
@@ -6385,7 +6368,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
activewindow=[activesecondsmin,activesecondsmax],)
|
|
|
|
activewindow=[activesecondsmin,activesecondsmax],)
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
messages.error(request,'Error updating Work per Stroke')
|
|
|
|
messages.error(request,'Error updating Work per Stroke')
|
|
|
|
elif powerorpace == 'spm':
|
|
|
|
elif powerorpace == 'spm': # pragma: no cover
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
rowdata.updateinterval_metric(' Cadence (stokes/min)',spm,mode='larger',
|
|
|
|
rowdata.updateinterval_metric(' Cadence (stokes/min)',spm,mode='larger',
|
|
|
|
debug=False,smoothwindow=2.,
|
|
|
|
debug=False,smoothwindow=2.,
|
|
|
|
@@ -6415,7 +6398,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
form = SummaryStringForm()
|
|
|
|
form = SummaryStringForm()
|
|
|
|
|
|
|
|
|
|
|
|
# we are saving the results obtained from the detailed form
|
|
|
|
# we are saving the results obtained from the detailed form
|
|
|
|
elif request.method == 'POST' and "savedetailform" in request.POST:
|
|
|
|
elif request.method == 'POST' and "savedetailform" in request.POST: # pragma: no cover
|
|
|
|
savebutton = 'savedetailform'
|
|
|
|
savebutton = 'savedetailform'
|
|
|
|
form = SummaryStringForm()
|
|
|
|
form = SummaryStringForm()
|
|
|
|
nrintervals = int(request.POST['nrintervals'])
|
|
|
|
nrintervals = int(request.POST['nrintervals'])
|
|
|
|
@@ -6481,7 +6464,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# we are processing the details form
|
|
|
|
# we are processing the details form
|
|
|
|
elif request.method == 'POST' and "nrintervals" in request.POST:
|
|
|
|
elif request.method == 'POST' and "nrintervals" in request.POST: # pragma: no cover
|
|
|
|
savebutton = 'savedetailform'
|
|
|
|
savebutton = 'savedetailform'
|
|
|
|
nrintervals = int(request.POST['nrintervals'])
|
|
|
|
nrintervals = int(request.POST['nrintervals'])
|
|
|
|
detailform = IntervalUpdateForm(request.POST,aantal=nrintervals)
|
|
|
|
detailform = IntervalUpdateForm(request.POST,aantal=nrintervals)
|
|
|
|
@@ -6533,7 +6516,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
initial['intervald_%s' % i] = idist[i]
|
|
|
|
initial['intervald_%s' % i] = idist[i]
|
|
|
|
initial['intervalt_%s' % i] = get_time(itime[i])
|
|
|
|
initial['intervalt_%s' % i] = get_time(itime[i])
|
|
|
|
initial['type_%s' % i] = itype[i]
|
|
|
|
initial['type_%s' % i] = itype[i]
|
|
|
|
except IndexError:
|
|
|
|
except IndexError: # pragma: no cover
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -6552,7 +6535,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
res = interactive_chart(encoder.decode_hex(id),promember=1,intervaldata=intervaldata)
|
|
|
|
res = interactive_chart(encoder.decode_hex(id),promember=1,intervaldata=intervaldata)
|
|
|
|
script = res[0]
|
|
|
|
script = res[0]
|
|
|
|
div = res[1]
|
|
|
|
div = res[1]
|
|
|
|
except ValueError:
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
script = ''
|
|
|
|
script = ''
|
|
|
|
div = ''
|
|
|
|
div = ''
|
|
|
|
|
|
|
|
|
|
|
|
@@ -6620,14 +6603,14 @@ class VideoDelete(DeleteView):
|
|
|
|
w = self.object.workout
|
|
|
|
w = self.object.workout
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
w = Workout.objects.get(id=w.id)
|
|
|
|
w = Workout.objects.get(id=w.id)
|
|
|
|
except Workout.DoesNotExist:
|
|
|
|
except Workout.DoesNotExist: # pragma: no cover
|
|
|
|
return reverse('workouts_view')
|
|
|
|
return reverse('workouts_view')
|
|
|
|
|
|
|
|
|
|
|
|
return reverse('workout_edit_view',kwargs={'id':encoder.encode_hex(w.id)})
|
|
|
|
return reverse('workout_edit_view',kwargs={'id':encoder.encode_hex(w.id)})
|
|
|
|
|
|
|
|
|
|
|
|
def get_object(self, *args, **kwargs):
|
|
|
|
def get_object(self, *args, **kwargs):
|
|
|
|
obj = super(VideoDelete, self).get_object(*args, **kwargs)
|
|
|
|
obj = super(VideoDelete, self).get_object(*args, **kwargs)
|
|
|
|
if not is_coach_user(self.request.user,obj.workout.user):
|
|
|
|
if not is_coach_user(self.request.user,obj.workout.user.user): # pragma: no cover
|
|
|
|
raise PermissionDenied('You are not allowed to delete this analysis')
|
|
|
|
raise PermissionDenied('You are not allowed to delete this analysis')
|
|
|
|
|
|
|
|
|
|
|
|
return obj
|
|
|
|
return obj
|
|
|
|
@@ -6673,7 +6656,7 @@ class GraphDelete(DeleteView):
|
|
|
|
w = self.object.workout
|
|
|
|
w = self.object.workout
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
w = Workout.objects.get(id=w.id)
|
|
|
|
w = Workout.objects.get(id=w.id)
|
|
|
|
except Workout.DoesNotExist:
|
|
|
|
except Workout.DoesNotExist: # pragma: no cover
|
|
|
|
return reverse('workouts_view')
|
|
|
|
return reverse('workouts_view')
|
|
|
|
|
|
|
|
|
|
|
|
return reverse('workout_edit_view',kwargs={'id':encoder.encode_hex(w.id)})
|
|
|
|
return reverse('workout_edit_view',kwargs={'id':encoder.encode_hex(w.id)})
|
|
|
|
@@ -6681,21 +6664,11 @@ class GraphDelete(DeleteView):
|
|
|
|
def get_object(self, *args, **kwargs):
|
|
|
|
def get_object(self, *args, **kwargs):
|
|
|
|
obj = super(GraphDelete, self).get_object(*args, **kwargs)
|
|
|
|
obj = super(GraphDelete, self).get_object(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
if not is_workout_user(self.request.user,obj.workout):
|
|
|
|
if not is_workout_user(self.request.user,obj.workout): # pragma: no cover
|
|
|
|
raise PermissionDenied('You are not allowed to delete this chart')
|
|
|
|
raise PermissionDenied('You are not allowed to delete this chart')
|
|
|
|
|
|
|
|
|
|
|
|
return obj
|
|
|
|
return obj
|
|
|
|
|
|
|
|
|
|
|
|
def workout_code_delete_view(request,id=0):
|
|
|
|
|
|
|
|
pk = encoder.decode_hex(id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
w = Workout.objects.get(pk=pk)
|
|
|
|
|
|
|
|
url = reverse('workout_delete',kwargs={'pk':pk})
|
|
|
|
|
|
|
|
except Workout.DoesNotExist:
|
|
|
|
|
|
|
|
url = reverse('workout_delete',kwargs={'pk':id})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return HttpResponseRedirect(url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WorkoutDelete(PermissionRequiredMixin,DeleteView):
|
|
|
|
class WorkoutDelete(PermissionRequiredMixin,DeleteView):
|
|
|
|
login_required = True
|
|
|
|
login_required = True
|
|
|
|
@@ -6753,7 +6726,7 @@ class WorkoutDelete(PermissionRequiredMixin,DeleteView):
|
|
|
|
workout_pk = encoder.decode_hex(workout_pk)
|
|
|
|
workout_pk = encoder.decode_hex(workout_pk)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
obj = Workout.objects.get(pk=workout_pk)
|
|
|
|
obj = Workout.objects.get(pk=workout_pk)
|
|
|
|
except Workout.DoesNotExist:
|
|
|
|
except Workout.DoesNotExist: # pragma: no cover
|
|
|
|
raise Http404("One of the workouts doesn't exist")
|
|
|
|
raise Http404("One of the workouts doesn't exist")
|
|
|
|
# obj = super(WorkoutDelete, self).get_object(*args, **kwargs)
|
|
|
|
# obj = super(WorkoutDelete, self).get_object(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|