Private
Public Access
1
0

Merge branch 'hotfix/v2.73'

This commit is contained in:
Sander Roosendaal
2017-05-11 20:50:52 +02:00
3 changed files with 16 additions and 11 deletions

View File

@@ -122,11 +122,18 @@ def get_token(code):
response = requests.post(url,
data=json.dumps(post_data),
headers=headers)
token_json = response.json()
thetoken = token_json['access_token']
expires_in = token_json['expires_in']
refresh_token = token_json['refresh_token']
if response.status_code == 200 or response.status_code == 201:
token_json = response.json()
thetoken = token_json['access_token']
expires_in = token_json['expires_in']
try:
refresh_token = token_json['refresh_token']
except KeyError:
refresh_token = refreshtoken
else:
return [0,0,0]
return [thetoken,expires_in,refresh_token]
# Make authorization URL including random string

View File

@@ -145,7 +145,7 @@ def do_refresh_token(refreshtoken):
data=post_data,
headers=headers)
if response.status_code == 200:
if response.status_code == 200 or response.status_code == 201:
token_json = response.json()
thetoken = token_json['access_token']
expires_in = token_json['expires_in']
@@ -316,9 +316,7 @@ def workout_tp_upload(user,w):
)
if res == 0:
message = "Upload to TrainingPeaks failed with status code "+str(status_code)+": "+reason
w.uploadedtotp = -1
w.tpid = -1
w.save()
try:
os.remove(tcxfile)
except WindowsError:

View File

@@ -1170,12 +1170,12 @@ def workout_tp_upload_view(request,id=0):
if (checkworkoutuser(request.user,w)):
tcxfile = tpstuff.createtpworkoutdata(w)
if tcxfile:
res,reason,status_code,headers = tpstuff.uploadactivity(r.tptoken,tcxfile,
name=w.name)
res,reason,status_code,headers = tpstuff.uploadactivity(
r.tptoken,tcxfile,
name=w.name
)
if res == 0:
message = "Upload to TrainingPeaks failed with status code "+str(status_code)+": "+reason
w.uploadedtotp = -1
w.save()
try:
os.remove(tcxfile)
except WindowsError: