changes to accomodate the golang implementation
This commit is contained in:
@@ -5,6 +5,9 @@ from __future__ import unicode_literals
|
|||||||
from six import iteritems
|
from six import iteritems
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
workouttypes_ordered = collections.OrderedDict({
|
workouttypes_ordered = collections.OrderedDict({
|
||||||
'water':'Standard Racing Shell',
|
'water':'Standard Racing Shell',
|
||||||
'rower':'Indoor Rower',
|
'rower':'Indoor Rower',
|
||||||
@@ -289,7 +292,7 @@ workoutsources = (
|
|||||||
('ergstick','ergstick'),
|
('ergstick','ergstick'),
|
||||||
('fit','fit'),
|
('fit','fit'),
|
||||||
('unknown','unknown'))
|
('unknown','unknown'))
|
||||||
|
|
||||||
boattypes = (
|
boattypes = (
|
||||||
('1x', '1x (single)'),
|
('1x', '1x (single)'),
|
||||||
('2x', '2x (double)'),
|
('2x', '2x (double)'),
|
||||||
|
|||||||
@@ -4394,6 +4394,15 @@ def workout_upload_api(request):
|
|||||||
message = {'status':'false','message':'this view cannot be accessed through GET'}
|
message = {'status':'false','message':'this view cannot be accessed through GET'}
|
||||||
return JSONResponse(status=403,data=message)
|
return JSONResponse(status=403,data=message)
|
||||||
|
|
||||||
|
|
||||||
|
# test if JSON
|
||||||
|
try:
|
||||||
|
json_data = json.loads(request.body)
|
||||||
|
secret = json_data['secret']
|
||||||
|
post_data = json_data
|
||||||
|
except KeyError:
|
||||||
|
post_data = request.POST
|
||||||
|
|
||||||
# only allow local host
|
# only allow local host
|
||||||
hostt = request.get_host().split(':')
|
hostt = request.get_host().split(':')
|
||||||
if hostt[0] not in ['localhost','127.0.0.1']:
|
if hostt[0] not in ['localhost','127.0.0.1']:
|
||||||
@@ -4401,17 +4410,22 @@ def workout_upload_api(request):
|
|||||||
return JSONResponse(status=403,data=message)
|
return JSONResponse(status=403,data=message)
|
||||||
|
|
||||||
# check credentials here
|
# check credentials here
|
||||||
secret = request.POST['secret']
|
try:
|
||||||
|
secret = post_data['secret']
|
||||||
|
except KeyError:
|
||||||
|
message = {'status': 'false', 'message':'missing credentials'}
|
||||||
|
return JSONResponse(status=400,data=message)
|
||||||
if secret != settings.UPLOAD_SERVICE_SECRET:
|
if secret != settings.UPLOAD_SERVICE_SECRET:
|
||||||
message = {'status':'false','message':'invalid credentials'}
|
message = {'status':'false','message':'invalid credentials'}
|
||||||
return JSONResponse(status=403,data=message)
|
return JSONResponse(status=403,data=message)
|
||||||
|
|
||||||
form = DocumentsForm(request.POST)
|
form = DocumentsForm(post_data)
|
||||||
optionsform = TeamUploadOptionsForm(request.POST)
|
optionsform = TeamUploadOptionsForm(post_data)
|
||||||
rowerform = TeamInviteForm(request.POST)
|
rowerform = TeamInviteForm(post_data)
|
||||||
rowerform.fields.pop('email')
|
rowerform.fields.pop('email')
|
||||||
try:
|
try:
|
||||||
fstr = request.POST['file']
|
fstr = post_data['file']
|
||||||
|
print(fstr)
|
||||||
nn, ext = os.path.splitext(fstr)
|
nn, ext = os.path.splitext(fstr)
|
||||||
if ext== '.gz':
|
if ext== '.gz':
|
||||||
nn, ext2 = os.path.splitext(nn)
|
nn, ext2 = os.path.splitext(nn)
|
||||||
@@ -4433,8 +4447,8 @@ def workout_upload_api(request):
|
|||||||
if rowerform.is_valid():
|
if rowerform.is_valid():
|
||||||
u = rowerform.cleaned_data['user']
|
u = rowerform.cleaned_data['user']
|
||||||
r = getrower(u)
|
r = getrower(u)
|
||||||
elif 'useremail' in request.POST:
|
elif 'useremail' in post_data:
|
||||||
us = User.objects.filter(email=request.POST['useremail'])
|
us = User.objects.filter(email=post_data['useremail'])
|
||||||
if len(us):
|
if len(us):
|
||||||
u = us[0]
|
u = us[0]
|
||||||
r = getrower(u)
|
r = getrower(u)
|
||||||
|
|||||||
Reference in New Issue
Block a user