working on v2
This commit is contained in:
@@ -91,12 +91,12 @@ def strokedatajson_v2(request,id):
|
||||
|
||||
row = get_object_or_404(Workout,pk=id)
|
||||
if row.user != request.user.rower:
|
||||
raise PermissionDenied("You have no access to this workout")
|
||||
return HttpResponse("You do not have permission to perform this action",status=403)
|
||||
|
||||
try:
|
||||
id = int(id)
|
||||
except ValueError:
|
||||
return HttpResponse("Not a valid workout number",status=400)
|
||||
return HttpResponse("Not a valid workout number",status=404)
|
||||
|
||||
if request.method == 'GET':
|
||||
columns = ['spm','time','hr','pace','power','distance']
|
||||
@@ -112,19 +112,19 @@ def strokedatajson_v2(request,id):
|
||||
if request.method == 'POST':
|
||||
checkdata, r = dataprep.getrowdata_db(id=row.id)
|
||||
if not checkdata.empty:
|
||||
return HttpResponse("Duplicate Error",status=400)
|
||||
return HttpResponse("Duplicate Error",status=403)
|
||||
|
||||
df = pd.DataFrame()
|
||||
print(request.POST)
|
||||
|
||||
try:
|
||||
df = pd.read_json(request.POST['data'],orient='split')
|
||||
df = pd.DataFrame(request.data['data'])
|
||||
except KeyError:
|
||||
try:
|
||||
df = pd.read_json(request.POST['strokedata'],orient='split')
|
||||
df = pd.DataFrame(request.data['strokedata'])
|
||||
except:
|
||||
return HttpResponse("No JSON object could be decoded",status=400)
|
||||
|
||||
|
||||
df.index = df.index.astype(int)
|
||||
df.sort_index(inplace=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user