Merge branch 'hotfix/v2.73'
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user