correct status code
This commit is contained in:
@@ -96,7 +96,7 @@ def strokedatajson_v2(request,id):
|
|||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return HttpResponse("Not a valid workout number",stauts=400)
|
return HttpResponse("Not a valid workout number",status=400)
|
||||||
|
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
columns = ['spm','time','hr','pace','power','distance']
|
columns = ['spm','time','hr','pace','power','distance']
|
||||||
@@ -112,9 +112,10 @@ def strokedatajson_v2(request,id):
|
|||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
checkdata, r = dataprep.getrowdata_db(id=row.id)
|
checkdata, r = dataprep.getrowdata_db(id=row.id)
|
||||||
if not checkdata.empty:
|
if not checkdata.empty:
|
||||||
return HttpResponse("Duplicate Error",400)
|
return HttpResponse("Duplicate Error",status=400)
|
||||||
|
|
||||||
df = pd.DataFrame()
|
df = pd.DataFrame()
|
||||||
|
print(request.POST)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
df = pd.read_json(request.POST['data'],orient='split')
|
df = pd.read_json(request.POST['data'],orient='split')
|
||||||
@@ -122,7 +123,7 @@ def strokedatajson_v2(request,id):
|
|||||||
try:
|
try:
|
||||||
df = pd.read_json(request.POST['strokedata'],orient='split')
|
df = pd.read_json(request.POST['strokedata'],orient='split')
|
||||||
except:
|
except:
|
||||||
return HttpResponse("No JSON object could be decoded",400)
|
return HttpResponse("No JSON object could be decoded",status=400)
|
||||||
|
|
||||||
df.index = df.index.astype(int)
|
df.index = df.index.astype(int)
|
||||||
df.sort_index(inplace=True)
|
df.sort_index(inplace=True)
|
||||||
@@ -134,12 +135,12 @@ def strokedatajson_v2(request,id):
|
|||||||
try:
|
try:
|
||||||
time = df['t']/10.
|
time = df['t']/10.
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return HttpResponse("Missing time",400)
|
return HttpResponse("Missing time",status=400)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
spm = df['spm']
|
spm = df['spm']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return HttpResponse("Missing spm",400)
|
return HttpResponse("Missing spm",status=400)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
distance = df['distance']
|
distance = df['distance']
|
||||||
@@ -147,7 +148,7 @@ def strokedatajson_v2(request,id):
|
|||||||
try:
|
try:
|
||||||
distance = df['d']/10.
|
distance = df['d']/10.
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return HttpResponse("Missing distance",400)
|
return HttpResponse("Missing distance",status=400)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pace = df['pace']/1.e3
|
pace = df['pace']/1.e3
|
||||||
@@ -155,7 +156,7 @@ def strokedatajson_v2(request,id):
|
|||||||
try:
|
try:
|
||||||
pace = df['p']/10.
|
pace = df['p']/10.
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return HttpResponse("Missing pace",400)
|
return HttpResponse("Missing pace",status=400)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -320,13 +321,13 @@ def strokedatajson(request,id):
|
|||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
checkdata,r = dataprep.getrowdata_db(id=row.id)
|
checkdata,r = dataprep.getrowdata_db(id=row.id)
|
||||||
if not checkdata.empty:
|
if not checkdata.empty:
|
||||||
return HttpResponse("Duplicate Error",409)
|
return HttpResponse("Duplicate Error",status=409)
|
||||||
# strokedata = request.POST['strokedata']
|
# strokedata = request.POST['strokedata']
|
||||||
# checking/validating and cleaning
|
# checking/validating and cleaning
|
||||||
try:
|
try:
|
||||||
strokedata = json.loads(request.POST['strokedata'])
|
strokedata = json.loads(request.POST['strokedata'])
|
||||||
except:
|
except:
|
||||||
return HttpResponse("No JSON object could be decoded",400)
|
return HttpResponse("No JSON object could be decoded",status=400)
|
||||||
|
|
||||||
df = pd.DataFrame(strokedata)
|
df = pd.DataFrame(strokedata)
|
||||||
df.index = df.index.astype(int)
|
df.index = df.index.astype(int)
|
||||||
|
|||||||
Reference in New Issue
Block a user