|
|
|
|
@@ -669,7 +669,7 @@ def addmanual_view(request,raceid=0):
|
|
|
|
|
if iform.is_valid(): # this works but cannot get the tests to work
|
|
|
|
|
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)
|
|
|
|
|
try:
|
|
|
|
|
width, height = Image.open(path_and_filename).size
|
|
|
|
|
@@ -4377,10 +4377,10 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|
|
|
|
if dragchanged:
|
|
|
|
|
try: # pragma: no cover
|
|
|
|
|
r.change_drag(newdragfactor)
|
|
|
|
|
except AttributeError:
|
|
|
|
|
except AttributeError: # pragma: no cover
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
if r == 0:
|
|
|
|
|
if r == 0: # pragma: no cover
|
|
|
|
|
return HttpResponse("Error: CSV Data File Not Found")
|
|
|
|
|
r.rowdatetime = startdatetime
|
|
|
|
|
r.write_csv(row.csvfilename,gzip=True)
|
|
|
|
|
@@ -4517,12 +4517,12 @@ def workout_map_view(request,id=0):
|
|
|
|
|
if rowdata != 0:
|
|
|
|
|
try:
|
|
|
|
|
latitude = rowdata.df[' latitude']
|
|
|
|
|
if not latitude.std():
|
|
|
|
|
if not latitude.std(): # pragma: no cover
|
|
|
|
|
hascoordinates = 0
|
|
|
|
|
except (KeyError,AttributeError):
|
|
|
|
|
hascoordinates = 0
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
else: # pragma: no cover
|
|
|
|
|
hascoordinates = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -4761,7 +4761,7 @@ def workout_upload_api(request):
|
|
|
|
|
try:
|
|
|
|
|
fstr = post_data['file']
|
|
|
|
|
nn, ext = os.path.splitext(fstr)
|
|
|
|
|
if ext== '.gz':
|
|
|
|
|
if ext== '.gz': # pragma: no cover
|
|
|
|
|
nn, ext2 = os.path.splitext(nn)
|
|
|
|
|
ext = ext2+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']
|
|
|
|
|
try: # pragma: no cover
|
|
|
|
|
rpe = int(rpe)
|
|
|
|
|
except ValueError:
|
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
|
rpe = 0
|
|
|
|
|
if not rpe:
|
|
|
|
|
if not rpe: # pragma: no cover
|
|
|
|
|
rpe = -1
|
|
|
|
|
except KeyError:
|
|
|
|
|
rpe = -1
|
|
|
|
|
@@ -5139,15 +5139,15 @@ def workout_upload_view(request,
|
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
if not id:
|
|
|
|
|
if not id: # pragma: no cover
|
|
|
|
|
messages.error(request,message)
|
|
|
|
|
url = reverse('workout_upload_view')
|
|
|
|
|
if is_ajax:
|
|
|
|
|
if is_ajax: # pragma: no cover
|
|
|
|
|
return JSONResponse({'result':0,'url':url})
|
|
|
|
|
else:
|
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
|
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.'
|
|
|
|
|
messages.info(request,message)
|
|
|
|
|
url = reverse('workout_upload_view')
|
|
|
|
|
@@ -5157,7 +5157,7 @@ def workout_upload_view(request,
|
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
|
return response
|
|
|
|
|
else:
|
|
|
|
|
if message:
|
|
|
|
|
if message: # pragma: no cover
|
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
w = Workout.objects.get(id=id)
|
|
|
|
|
@@ -5167,14 +5167,14 @@ def workout_upload_view(request,
|
|
|
|
|
'id':encoder.encode_hex(w.id),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if is_ajax:
|
|
|
|
|
if is_ajax: # pragma: no cover
|
|
|
|
|
response = {'result': 1,'url':url}
|
|
|
|
|
else:
|
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r = getrower(request.user)
|
|
|
|
|
if (make_plot):
|
|
|
|
|
if (make_plot): # pragma: no cover
|
|
|
|
|
res,jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
|
|
|
|
|
if res == 0:
|
|
|
|
|
messages.error(request,jobid)
|
|
|
|
|
@@ -5188,7 +5188,7 @@ def workout_upload_view(request,
|
|
|
|
|
res, jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
|
|
|
|
|
|
|
|
|
|
# upload to C2
|
|
|
|
|
if (upload_to_c2):
|
|
|
|
|
if (upload_to_c2): # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
message,id = c2stuff.workout_c2_upload(request.user,w)
|
|
|
|
|
except NoTokenError:
|
|
|
|
|
@@ -5199,7 +5199,7 @@ def workout_upload_view(request,
|
|
|
|
|
else:
|
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
if (upload_to_strava):
|
|
|
|
|
if (upload_to_strava): # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
message,id = stravastuff.workout_strava_upload(
|
|
|
|
|
request.user,w,
|
|
|
|
|
@@ -5212,7 +5212,7 @@ def workout_upload_view(request,
|
|
|
|
|
else:
|
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
if (upload_to_st):
|
|
|
|
|
if (upload_to_st): # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
message,id = sporttracksstuff.workout_sporttracks_upload(
|
|
|
|
|
request.user,w
|
|
|
|
|
@@ -5225,7 +5225,7 @@ def workout_upload_view(request,
|
|
|
|
|
else:
|
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
if (upload_to_rk):
|
|
|
|
|
if (upload_to_rk): # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
message,id = runkeeperstuff.workout_runkeeper_upload(
|
|
|
|
|
request.user,w
|
|
|
|
|
@@ -5240,7 +5240,7 @@ def workout_upload_view(request,
|
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (upload_to_ua):
|
|
|
|
|
if (upload_to_ua): # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
message,id = underarmourstuff.workout_ua_upload(
|
|
|
|
|
request.user,w
|
|
|
|
|
@@ -5255,7 +5255,7 @@ def workout_upload_view(request,
|
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (upload_to_tp):
|
|
|
|
|
if (upload_to_tp): # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
message,id = tpstuff.workout_tp_upload(
|
|
|
|
|
request.user,w
|
|
|
|
|
@@ -5269,7 +5269,7 @@ def workout_upload_view(request,
|
|
|
|
|
else:
|
|
|
|
|
messages.error(request,message)
|
|
|
|
|
|
|
|
|
|
if int(registrationid) < 0:
|
|
|
|
|
if int(registrationid) < 0: # pragma: no cover
|
|
|
|
|
race = VirtualRace.objects.get(id=-int(registrationid))
|
|
|
|
|
if race.sessiontype == 'race':
|
|
|
|
|
result,comments,errors,jobid = add_workout_race(
|
|
|
|
|
@@ -5309,7 +5309,7 @@ def workout_upload_view(request,
|
|
|
|
|
for er in errors:
|
|
|
|
|
messages.error(request,er)
|
|
|
|
|
|
|
|
|
|
if int(registrationid)>0:
|
|
|
|
|
if int(registrationid)>0: # pragma: no cover
|
|
|
|
|
races = VirtualRace.objects.filter(
|
|
|
|
|
registration_closure__gt=timezone.now()
|
|
|
|
|
)
|
|
|
|
|
@@ -5330,7 +5330,7 @@ def workout_upload_view(request,
|
|
|
|
|
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
|
|
|
|
|
registrations = registrations.filter(id=registrationid)
|
|
|
|
|
if registrations:
|
|
|
|
|
@@ -5355,7 +5355,7 @@ def workout_upload_view(request,
|
|
|
|
|
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
|
|
|
|
|
registrations = registrations2.filter(id=registrationid)
|
|
|
|
|
if registrations:
|
|
|
|
|
@@ -5380,7 +5380,7 @@ def workout_upload_view(request,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if registrationid != 0:
|
|
|
|
|
if registrationid != 0: # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
url = reverse('virtualevent_view',
|
|
|
|
|
kwargs = {
|
|
|
|
|
@@ -5392,23 +5392,23 @@ def workout_upload_view(request,
|
|
|
|
|
kwargs = {
|
|
|
|
|
'id':encoder.encode_hex(w.id),
|
|
|
|
|
})
|
|
|
|
|
else:
|
|
|
|
|
else: # pragma: no cover
|
|
|
|
|
url = reverse(landingpage)
|
|
|
|
|
elif landingpage != 'workout_upload_view':
|
|
|
|
|
elif landingpage != 'workout_upload_view': # pragma: no cover
|
|
|
|
|
url = reverse(landingpage,
|
|
|
|
|
kwargs = {
|
|
|
|
|
'id':encoder.encode_hex(w.id),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
else: # pragma: no cover
|
|
|
|
|
url = reverse(landingpage)
|
|
|
|
|
|
|
|
|
|
if is_ajax:
|
|
|
|
|
if is_ajax: # pragma: no cover
|
|
|
|
|
response = {'result':1,'url':url}
|
|
|
|
|
else:
|
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
|
else:
|
|
|
|
|
if not is_ajax:
|
|
|
|
|
if not is_ajax: # pragma: no cover
|
|
|
|
|
response = render(request,
|
|
|
|
|
'document_form.html',
|
|
|
|
|
{'form':form,
|
|
|
|
|
@@ -5417,28 +5417,28 @@ def workout_upload_view(request,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if is_ajax:
|
|
|
|
|
if is_ajax: # pragma: no cover
|
|
|
|
|
return JSONResponse(response)
|
|
|
|
|
else:
|
|
|
|
|
return response
|
|
|
|
|
else:
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
form = DocumentsForm(initial=docformoptions)
|
|
|
|
|
@@ -5451,7 +5451,7 @@ def workout_upload_view(request,
|
|
|
|
|
'teams':get_my_teams(request.user),
|
|
|
|
|
'optionsform': optionsform,
|
|
|
|
|
})
|
|
|
|
|
else:
|
|
|
|
|
else: # pragma: no cover
|
|
|
|
|
return {'result':0}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -5499,7 +5499,7 @@ def team_workout_upload_view(request,message="",
|
|
|
|
|
).exclude(
|
|
|
|
|
rowerplan='freecoach'
|
|
|
|
|
).distinct()
|
|
|
|
|
if r.rowerplan == 'freecoach':
|
|
|
|
|
if r.rowerplan == 'freecoach': # pragma: no cover
|
|
|
|
|
rowers = rowers.exclude(rowerplan='basic')
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
if f:
|
|
|
|
|
res = handle_uploaded_file(f)
|
|
|
|
|
else:
|
|
|
|
|
else: # pragma: no cover
|
|
|
|
|
messages.error(request,'No file attached')
|
|
|
|
|
response = render(request,
|
|
|
|
|
'team_document_form.html',
|
|
|
|
|
@@ -5526,7 +5526,7 @@ def team_workout_upload_view(request,message="",
|
|
|
|
|
if rowerform.is_valid():
|
|
|
|
|
u = rowerform.cleaned_data['user']
|
|
|
|
|
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'
|
|
|
|
|
messages.error(request,message)
|
|
|
|
|
messages.info(request,successmessage)
|
|
|
|
|
@@ -5571,7 +5571,7 @@ def team_workout_upload_view(request,message="",
|
|
|
|
|
title = t,
|
|
|
|
|
notes=''
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
else: # pragma: no cover
|
|
|
|
|
job = myqueue(
|
|
|
|
|
queuehigh,
|
|
|
|
|
handle_zip_file,
|
|
|
|
|
@@ -5592,12 +5592,12 @@ def team_workout_upload_view(request,message="",
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not id:
|
|
|
|
|
if not id: # pragma: no cover
|
|
|
|
|
messages.error(request,message)
|
|
|
|
|
url = reverse('team_workout_upload_view')
|
|
|
|
|
response = HttpResponseRedirect(url)
|
|
|
|
|
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.'
|
|
|
|
|
messages.info(request,message)
|
|
|
|
|
url = reverse('team_workout_upload_view')
|
|
|
|
|
@@ -5614,7 +5614,7 @@ def team_workout_upload_view(request,message="",
|
|
|
|
|
w = Workout.objects.get(id=id)
|
|
|
|
|
|
|
|
|
|
r = getrower(request.user)
|
|
|
|
|
if (make_plot):
|
|
|
|
|
if (make_plot): # pragma: no cover
|
|
|
|
|
id,jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
|
|
|
|
|
elif r.staticchartonupload:
|
|
|
|
|
plottype = r.staticchartonupload
|
|
|
|
|
@@ -5647,7 +5647,7 @@ def team_workout_upload_view(request,message="",
|
|
|
|
|
).exclude(
|
|
|
|
|
rowerplan='freecoach'
|
|
|
|
|
).distinct()
|
|
|
|
|
if r.rowerplan == 'freecoach':
|
|
|
|
|
if r.rowerplan == 'freecoach': # pragma: no cover
|
|
|
|
|
rowers = rowers.exclude(rowerplan='basic')
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")
|
|
|
|
|
query = request.GET.get('q')
|
|
|
|
|
if query:
|
|
|
|
|
if query: # pragma: no cover
|
|
|
|
|
query_list = query.split()
|
|
|
|
|
if query:
|
|
|
|
|
query_list = query.split()
|
|
|
|
|
@@ -5695,7 +5695,7 @@ def list_videos(request,userid=0):
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
g = paginator.page(page)
|
|
|
|
|
except EmptyPage:
|
|
|
|
|
except EmptyPage: # pragma: no cover
|
|
|
|
|
g = paginator.page(paginator.num_pages)
|
|
|
|
|
|
|
|
|
|
return render(request, 'list_videos.html',
|
|
|
|
|
@@ -5712,7 +5712,7 @@ def graphs_view(request,userid=0):
|
|
|
|
|
r = getrequestrower(request,userid=userid)
|
|
|
|
|
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")
|
|
|
|
|
query = request.GET.get('q')
|
|
|
|
|
if query:
|
|
|
|
|
if query: # pragma: no cover
|
|
|
|
|
query_list = query.split()
|
|
|
|
|
workouts = workouts.filter(
|
|
|
|
|
reduce(operator.and_,
|
|
|
|
|
@@ -5734,7 +5734,7 @@ def graphs_view(request,userid=0):
|
|
|
|
|
g = paginator.page(page)
|
|
|
|
|
except PageNotAnInteger:
|
|
|
|
|
g = paginator.page(1)
|
|
|
|
|
except EmptyPage:
|
|
|
|
|
except EmptyPage: # pragma: no cover
|
|
|
|
|
g = paginator.page(paginator.num_pages)
|
|
|
|
|
|
|
|
|
|
return render(request, 'list_graphs.html',
|
|
|
|
|
@@ -5751,7 +5751,7 @@ def graphs_view(request,userid=0):
|
|
|
|
|
def graph_show_view(request,id):
|
|
|
|
|
try:
|
|
|
|
|
g = GraphImage.objects.get(id=id)
|
|
|
|
|
try:
|
|
|
|
|
try: # pragma: no cover
|
|
|
|
|
width,height = Image.open(g.filename).size
|
|
|
|
|
g.width = width
|
|
|
|
|
g.height = height
|
|
|
|
|
@@ -5787,9 +5787,9 @@ def graph_show_view(request,id):
|
|
|
|
|
'active':'nav-workouts',
|
|
|
|
|
'rower':r,})
|
|
|
|
|
|
|
|
|
|
except GraphImage.DoesNotExist:
|
|
|
|
|
except GraphImage.DoesNotExist: # pragma: no cover
|
|
|
|
|
raise Http404("This graph doesn't exist")
|
|
|
|
|
except Workout.DoesNotExist:
|
|
|
|
|
except Workout.DoesNotExist: # pragma: no cover
|
|
|
|
|
raise Http404("This workout doesn't exist")
|
|
|
|
|
|
|
|
|
|
# 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")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if request.user == r:
|
|
|
|
|
if request.user == r: # pragma: no cover
|
|
|
|
|
url = reverse('workouts_view')
|
|
|
|
|
else:
|
|
|
|
|
mgrids = [team.id for team in Team.objects.filter(manager=request.user)]
|
|
|
|
|
rwrids = [team.id for team in r.team.all()]
|
|
|
|
|
teamids = list(set(mgrids) & set(rwrids))
|
|
|
|
|
if len(teamids) > 0:
|
|
|
|
|
if len(teamids) > 0: # pragma: no cover
|
|
|
|
|
teamid = teamids[0]
|
|
|
|
|
|
|
|
|
|
url = reverse('workouts_view',
|
|
|
|
|
@@ -5907,9 +5907,9 @@ def workout_split_view(request,id=0):
|
|
|
|
|
|
|
|
|
|
rowname = row.name
|
|
|
|
|
try:
|
|
|
|
|
if isinstance(rowname,unicode):
|
|
|
|
|
if isinstance(rowname,unicode): # pragma: no cover
|
|
|
|
|
rowname = rowname.encode('utf8')
|
|
|
|
|
elif isinstance(rowname, str):
|
|
|
|
|
elif isinstance(rowname, str): # pragma: no cover
|
|
|
|
|
rowname = rowname.decode('utf8')
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
@@ -5947,7 +5947,7 @@ def workout_fusion_view(request,id1=0,id2=1):
|
|
|
|
|
try:
|
|
|
|
|
id1 = encoder.decode_hex(id1)
|
|
|
|
|
id2 = encoder.decode_hex(id2)
|
|
|
|
|
except:
|
|
|
|
|
except: # pragma: no cover
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
r = getrower(request.user)
|
|
|
|
|
@@ -5957,9 +5957,9 @@ def workout_fusion_view(request,id1=0,id2=1):
|
|
|
|
|
w2 = Workout.objects.get(id=id2)
|
|
|
|
|
r = w1.user
|
|
|
|
|
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")
|
|
|
|
|
except Workout.DoesNotExist:
|
|
|
|
|
except Workout.DoesNotExist: # pragma: no cover
|
|
|
|
|
raise Http404("One of the workouts doesn't exist")
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
@@ -5969,7 +5969,7 @@ def workout_fusion_view(request,id1=0,id2=1):
|
|
|
|
|
columns = cd['columns']
|
|
|
|
|
timeoffset = cd['offset']
|
|
|
|
|
posneg = cd['posneg']
|
|
|
|
|
if posneg == 'neg':
|
|
|
|
|
if posneg == 'neg': # pragma: no cover
|
|
|
|
|
timeoffset = -timeoffset
|
|
|
|
|
|
|
|
|
|
# Create DataFrame
|
|
|
|
|
@@ -5980,7 +5980,7 @@ def workout_fusion_view(request,id1=0,id2=1):
|
|
|
|
|
title='Fused data',
|
|
|
|
|
parent=w1,
|
|
|
|
|
forceunit=forceunit)
|
|
|
|
|
if message != None:
|
|
|
|
|
if message != None: # pragma: no cover
|
|
|
|
|
messages.error(request,message)
|
|
|
|
|
else:
|
|
|
|
|
successmessage = 'Data fused'
|
|
|
|
|
@@ -6124,12 +6124,12 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
normw = int(normw)
|
|
|
|
|
except ValueError:
|
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
|
normw = 100
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
normp = int(normp)
|
|
|
|
|
except ValueError:
|
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
|
normp = 100
|
|
|
|
|
|
|
|
|
|
data = {
|
|
|
|
|
@@ -6160,7 +6160,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
s = cd["intervalstring"]
|
|
|
|
|
try:
|
|
|
|
|
rowdata.updateinterval_string(s)
|
|
|
|
|
except:
|
|
|
|
|
except: # pragma: no cover
|
|
|
|
|
messages.error(request,'Parsing error')
|
|
|
|
|
intervalstats = rowdata.allstats()
|
|
|
|
|
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
|
|
|
|
|
elif request.method == 'POST' and "savepowerpaceform" in request.POST:
|
|
|
|
|
try:
|
|
|
|
|
powerorpace = request.POST['powerorpace']
|
|
|
|
|
except:
|
|
|
|
|
powerorpace = 'pace'
|
|
|
|
|
try:
|
|
|
|
|
value_pace = request.POST['value_pace']
|
|
|
|
|
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
|
|
|
|
|
powerorpace = request.POST.get('powerorpace','pace')
|
|
|
|
|
value_pace = request.POST.get('value_pace',avpace)
|
|
|
|
|
value_power = request.POST.get('value_power',int(normp))
|
|
|
|
|
value_work = request.POST.get('value_work',int(normw))
|
|
|
|
|
value_spm = request.POST.get('value_spm',int(normspm))
|
|
|
|
|
activeminutesmin = request.POST.get('activeminutesmin',0)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
activeminutesmax = request.POST['activeminutesmax']
|
|
|
|
|
except:
|
|
|
|
|
except: # pragma: no cover
|
|
|
|
|
pass
|
|
|
|
|
try:
|
|
|
|
|
activesecondsmin = 60.*float(activeminutesmin)
|
|
|
|
|
activesecondsmax = 60.*float(activeminutesmax)
|
|
|
|
|
except ValueError:
|
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
|
activesecondsmin = 0
|
|
|
|
|
activeminutesmin = 0
|
|
|
|
|
activeminutesmax = maxminutes
|
|
|
|
|
activesecondsmax = rowdata.duration
|
|
|
|
|
|
|
|
|
|
if abs(rowdata.duration-activesecondsmax) < 60.:
|
|
|
|
|
if abs(rowdata.duration-activesecondsmax) < 60.: # pragma: no cover
|
|
|
|
|
activesecondsmax = rowdata.duration
|
|
|
|
|
if powerorpace == 'power':
|
|
|
|
|
try:
|
|
|
|
|
power = int(value_power)
|
|
|
|
|
except ValueError:
|
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
|
int(normp)
|
|
|
|
|
elif powerorpace == 'pace':
|
|
|
|
|
elif powerorpace == 'pace': # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
pace_secs = float(value_pace)
|
|
|
|
|
except ValueError:
|
|
|
|
|
@@ -6222,12 +6205,12 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
pace_secs = float(value_pace.replace(',','.'))
|
|
|
|
|
except ValueError:
|
|
|
|
|
pace_secs = int(500./normv)
|
|
|
|
|
elif powerorpace == 'work':
|
|
|
|
|
elif powerorpace == 'work': # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
work = int(value_work)
|
|
|
|
|
except ValueError:
|
|
|
|
|
work = int(normw)
|
|
|
|
|
elif powerorpace == 'spm':
|
|
|
|
|
elif powerorpace == 'spm': # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
spm = int(value_spm)
|
|
|
|
|
except ValueError:
|
|
|
|
|
@@ -6240,9 +6223,9 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
debug=False,smoothwindow=15.,
|
|
|
|
|
activewindow=[activesecondsmin,activesecondsmax],
|
|
|
|
|
)
|
|
|
|
|
except:
|
|
|
|
|
except: # pragma: no cover
|
|
|
|
|
messages.error(request,'Error updating power')
|
|
|
|
|
elif powerorpace == 'pace':
|
|
|
|
|
elif powerorpace == 'pace': # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
velo = 500./pace_secs
|
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
|
@@ -6252,7 +6235,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
)
|
|
|
|
|
except:
|
|
|
|
|
messages.error(request,'Error updating pace')
|
|
|
|
|
elif powerorpace == 'work':
|
|
|
|
|
elif powerorpace == 'work': # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
|
'driveenergy',work,mode='larger',
|
|
|
|
|
@@ -6261,7 +6244,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
)
|
|
|
|
|
except:
|
|
|
|
|
messages.error(request,'Error updating Work per Stroke')
|
|
|
|
|
elif powerorpace == 'spm':
|
|
|
|
|
elif powerorpace == 'spm': # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
|
' Cadence (stokes/min)',spm,mode='larger',
|
|
|
|
|
@@ -6307,7 +6290,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
s = request.POST["savestringform"]
|
|
|
|
|
try:
|
|
|
|
|
rowdata.updateinterval_string(s)
|
|
|
|
|
except (ParseException,err):
|
|
|
|
|
except (ParseException,err): # pragma: no cover
|
|
|
|
|
messages.error(request,'Parsing error in column '+str(err.col))
|
|
|
|
|
|
|
|
|
|
intervalstats = rowdata.allstats()
|
|
|
|
|
@@ -6321,7 +6304,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
n = row.notes,
|
|
|
|
|
s = s
|
|
|
|
|
)
|
|
|
|
|
except TypeError:
|
|
|
|
|
except TypeError: # pragma: no cover
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
row.save()
|
|
|
|
|
@@ -6355,11 +6338,11 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
activeminutesmax = cd['activeminutesmax']
|
|
|
|
|
activesecondsmin = 60.*activeminutesmin
|
|
|
|
|
activesecondsmax = 60.*activeminutesmax
|
|
|
|
|
if abs(rowdata.duration-activesecondsmax) < 60.:
|
|
|
|
|
if abs(rowdata.duration-activesecondsmax) < 60.: # pragma: no cover
|
|
|
|
|
activesecondsmax = rowdata.duration
|
|
|
|
|
try:
|
|
|
|
|
pace_secs = pace.seconds+pace.microseconds/1.0e6
|
|
|
|
|
except AttributeError:
|
|
|
|
|
except AttributeError: # pragma: no cover
|
|
|
|
|
pace_secs = 120.
|
|
|
|
|
|
|
|
|
|
if powerorpace == 'power' and power is not None:
|
|
|
|
|
@@ -6368,7 +6351,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
activewindow=[activesecondsmin,activesecondsmax],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
elif powerorpace == 'pace':
|
|
|
|
|
elif powerorpace == 'pace': # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
velo = 500./pace_secs
|
|
|
|
|
rowdata.updateinterval_metric(' AverageBoatSpeed (m/s)',velo,mode='larger',
|
|
|
|
|
@@ -6377,7 +6360,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
)
|
|
|
|
|
except:
|
|
|
|
|
messages.error(request,'Error updating pace')
|
|
|
|
|
elif powerorpace == 'work':
|
|
|
|
|
elif powerorpace == 'work': # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
rowdata.updateinterval_metric(
|
|
|
|
|
'driveenergy',work,mode='larger',
|
|
|
|
|
@@ -6385,7 +6368,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
activewindow=[activesecondsmin,activesecondsmax],)
|
|
|
|
|
except:
|
|
|
|
|
messages.error(request,'Error updating Work per Stroke')
|
|
|
|
|
elif powerorpace == 'spm':
|
|
|
|
|
elif powerorpace == 'spm': # pragma: no cover
|
|
|
|
|
try:
|
|
|
|
|
rowdata.updateinterval_metric(' Cadence (stokes/min)',spm,mode='larger',
|
|
|
|
|
debug=False,smoothwindow=2.,
|
|
|
|
|
@@ -6415,7 +6398,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
form = SummaryStringForm()
|
|
|
|
|
|
|
|
|
|
# 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'
|
|
|
|
|
form = SummaryStringForm()
|
|
|
|
|
nrintervals = int(request.POST['nrintervals'])
|
|
|
|
|
@@ -6481,7 +6464,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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'
|
|
|
|
|
nrintervals = int(request.POST['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['intervalt_%s' % i] = get_time(itime[i])
|
|
|
|
|
initial['type_%s' % i] = itype[i]
|
|
|
|
|
except IndexError:
|
|
|
|
|
except IndexError: # pragma: no cover
|
|
|
|
|
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)
|
|
|
|
|
script = res[0]
|
|
|
|
|
div = res[1]
|
|
|
|
|
except ValueError:
|
|
|
|
|
except ValueError: # pragma: no cover
|
|
|
|
|
script = ''
|
|
|
|
|
div = ''
|
|
|
|
|
|
|
|
|
|
@@ -6620,14 +6603,14 @@ class VideoDelete(DeleteView):
|
|
|
|
|
w = self.object.workout
|
|
|
|
|
try:
|
|
|
|
|
w = Workout.objects.get(id=w.id)
|
|
|
|
|
except Workout.DoesNotExist:
|
|
|
|
|
except Workout.DoesNotExist: # pragma: no cover
|
|
|
|
|
return reverse('workouts_view')
|
|
|
|
|
|
|
|
|
|
return reverse('workout_edit_view',kwargs={'id':encoder.encode_hex(w.id)})
|
|
|
|
|
|
|
|
|
|
def get_object(self, *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')
|
|
|
|
|
|
|
|
|
|
return obj
|
|
|
|
|
@@ -6673,7 +6656,7 @@ class GraphDelete(DeleteView):
|
|
|
|
|
w = self.object.workout
|
|
|
|
|
try:
|
|
|
|
|
w = Workout.objects.get(id=w.id)
|
|
|
|
|
except Workout.DoesNotExist:
|
|
|
|
|
except Workout.DoesNotExist: # pragma: no cover
|
|
|
|
|
return reverse('workouts_view')
|
|
|
|
|
|
|
|
|
|
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):
|
|
|
|
|
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')
|
|
|
|
|
|
|
|
|
|
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):
|
|
|
|
|
login_required = True
|
|
|
|
|
@@ -6753,7 +6726,7 @@ class WorkoutDelete(PermissionRequiredMixin,DeleteView):
|
|
|
|
|
workout_pk = encoder.decode_hex(workout_pk)
|
|
|
|
|
try:
|
|
|
|
|
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")
|
|
|
|
|
# obj = super(WorkoutDelete, self).get_object(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|