Private
Public Access
1
0

refactoring

This commit is contained in:
Sander Roosendaal
2021-04-08 08:43:15 +02:00
parent 5335213527
commit 5b3eddbf9f

View File

@@ -4905,59 +4905,24 @@ def workout_upload_api(request):
message = {'status':'false','message':'could not find file'} message = {'status':'false','message':'could not find file'}
return JSONResponse(status=400,data=message) return JSONResponse(status=400,data=message)
try: # sync related IDs
stravaid = post_data['stravaid'] stravaid = post_data.get('stravaid','')
except KeyError: c2id = post_data.get('c2id','')
stravaid = '' nkid = post_data.get('nkid','')
rp3id = post_data.get('nkid','')
garminid = post_data.get('garminid',0)
try: startdatetime = post_data.get('startdatetime','')
c2id = post_data['c2id'] oarlockfirmware = post_data.get('oarlockfirmware',None)
except KeyError: inboard = post_data.get('inboard',None)
c2id = '' oarlength = post_data.get('oarlength',None)
useImpeller = post_data.get('useImpeller',False)
try: totalDistance = post_data.get('totalDistance',None)
nkid = post_data['nkid'] elapsedTime = post_data.get('elapsedTime',None)
except KeyError: summary = post_data.get('summary',None)
nkid = ''
try:
rp3id = post_data['rp3id']
except KeyError:
rp3id = ''
try:
garminid = post_data['garminid']
except KeyError:
garminid = 0
try:
startdatetime = post_data['startdatetime']
except KeyError:
startdatetime = ''
try:
oarlockfirmware = post_data['oarlockfirmware']
except:
oarlockfirmware = None
try:
inboard = post_data['inboard']
except:
inboard = None
try:
oarlength = post_data['oarlength']
except:
oarlength = None
try:
useImpeller = post_data['useImpeller']
except:
useImpeller = False
r = None r = None
if form.is_valid(): if form.is_valid():
t = form.cleaned_data['title'] t = form.cleaned_data['title']
@@ -5056,36 +5021,23 @@ def workout_upload_api(request):
plottype = r.staticchartonupload plottype = r.staticchartonupload
res, jobid = uploads.make_plot(r,w,f1,f2,plottype,t) res, jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
try: if inboard:
oarlength = post_data['oarlength']
inboard = post_data['inboard']
w.inboard = inboard w.inboard = inboard
w.save()
if oarlength:
w.oarlength = oarlength w.oarlength = oarlength
w.save() w.save()
except KeyError:
pass
try: if totalDistance:
totalDistance = post_data['totalDistance']
w.distance = totalDistance w.distance = totalDistance
w.save() w.save()
except KeyError:
pass
try: if elapsedTime:
elapsedTime = post_data['elapsedTime']
w.duration = totaltime_sec_to_string(elapsedTime) w.duration = totaltime_sec_to_string(elapsedTime)
except KeyError:
pass
if summary:
try:
summary = post_data['summary']
w.summary = summary w.summary = summary
w.save() w.save()
except KeyError:
pass
uploads.do_sync(w,post_data,quick=True) uploads.do_sync(w,post_data,quick=True)