Private
Public Access
1
0

bug fixes

This commit is contained in:
Sander Roosendaal
2020-02-18 21:37:13 +01:00
parent fc6dd7e347
commit 38094d7b13
6 changed files with 35 additions and 33 deletions

View File

@@ -19,7 +19,7 @@ def strokedataform(request,id=0):
w = Workout.objects.get(id=id)
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
if request.method == 'GET':
form = StrokeDataForm()
return render(request, 'strokedata_form.html',
@@ -52,7 +52,9 @@ def strokedatajson(request,id):
POST: Add Stroke data to workout
GET: Get stroke data of workout
"""
row = get_workout_permitted(request.user,id)
row = get_object_or_404(Workout,pk=id)
if row.user != request.user.rower:
raise PermissionDenied("You have no access to this workout")
try:
id = int(id)
@@ -61,7 +63,7 @@ def strokedatajson(request,id):
if request.method == 'GET':
# currently only returns a subset.
# currently only returns a subset.
columns = ['spm','time','hr','pace','power','distance']
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
with open('media/apilog.log','a') as logfile:
@@ -95,7 +97,7 @@ def strokedatajson(request,id):
distance = df['distance']
if len(distance) != aantal:
return HttpResponse("Distance array has incorrect length",status=400)
spm = df['spm']
if len(spm) != aantal:
return HttpResponse("SPM array has incorrect length",status=400)
@@ -103,7 +105,7 @@ def strokedatajson(request,id):
res = dataprep.testdata(time,distance,pace,spm)
if not res:
return HttpResponse("Data are not numerical",status=400)
power = trydf(df,aantal,'power')
drivelength = trydf(df,aantal,'drivelength')
drivespeed = trydf(df,aantal,'drivespeed')
@@ -127,7 +129,7 @@ def strokedatajson(request,id):
with open('media/apilog.log','a') as logfile:
logfile.write(str(starttime)+": ")
logfile.write(request.user.username+"(POST) \r\n")
data = pd.DataFrame({'TimeStamp (sec)':unixtime,
' Horizontal (meters)': distance,
' Cadence (stokes/min)':spm,
@@ -155,7 +157,7 @@ def strokedatajson(request,id):
timestr = row.startdatetime.strftime("%Y%m%d-%H%M%S")
csvfilename ='media/Import_'+timestr+'.csv'
res = data.to_csv(csvfilename+'.gz',index_label='index',
compression='gzip')
row.csvfilename = csvfilename
@@ -169,14 +171,14 @@ def strokedatajson(request,id):
ftp = float(r.ftp)
if row.workouttype in mytypes.otwtypes:
ftp = ftp*(100.-r.otwslack)/100.
rr = rrower(hrmax=r.max,hrut2=r.ut2,
hrut1=r.ut1,hrat=r.at,
hrtr=r.tr,hran=r.an,ftp=ftp,
powerperc=powerperc,powerzones=r.powerzones)
rowdata = rdata(row.csvfilename,rower=rr).df
datadf = dataprep.dataprep(rowdata,id=row.id,bands=True,barchart=True,otwpower=True,empower=True)
datadf = dataprep.dataprep(rowdata,id=row.id,bands=True,barchart=True,otwpower=True,empower=True)
# mangling
#

View File

@@ -82,7 +82,7 @@ def workout_strava_upload_view(request,id=0):
return HttpResponseRedirect("/rowers/me/stravaauthorize/")
else:
# ready to upload. Hurray
w = get_workout_permitted(request.user,id)
w = get_workout_by_opaqueid(request,id)
r = w.user
try:

View File

@@ -4406,7 +4406,6 @@ def workout_upload_api(request):
except (KeyError,JSONDecodeError):
post_data = request.POST
# only allow local host
hostt = request.get_host().split(':')
if hostt[0] not in ['localhost','127.0.0.1','dev.rowsandall.com','rowsandall.com']:
@@ -4491,6 +4490,7 @@ def workout_upload_api(request):
makeprivate=makeprivate,
title = t,
notes=notes,
uploadoptions=post_data,
)
if id == 0: