From d703438fd2fdf392202ae266ab518520674ccaaa Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 4 May 2017 08:07:50 +0200 Subject: [PATCH] mention error status in TP --- rowers/tpstuff.py | 4 ++-- rowers/views.py | 13 ++++++------- rowsandall_app/settings.py | 3 +-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/rowers/tpstuff.py b/rowers/tpstuff.py index 1c90d975..43c6c042 100644 --- a/rowers/tpstuff.py +++ b/rowers/tpstuff.py @@ -245,9 +245,9 @@ def uploadactivity(access_token,filename,description='', print "" print headers print "" - return 0 + return 0,"ok",200 else: - return resp.json()[0]["Id"] + return resp.json()[0]["Id"],resp.reason,resp.status_code return 0 diff --git a/rowers/views.py b/rowers/views.py index 1a193896..6b942cf1 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -1230,10 +1230,10 @@ def workout_tp_upload_view(request,id=0): message = "" r = Rower.objects.get(user=request.user) res = -1 - try: - thetoken = tp_open(r.user) - except TPNoTokenError: - return HttpResponseRedirect("/rowers/me/tpauthorize/") + # try: + thetoken = tp_open(r.user) + # except TPNoTokenError: + # return HttpResponseRedirect("/rowers/me/tpauthorize/") # ready to upload. Hurray try: @@ -1244,10 +1244,10 @@ def workout_tp_upload_view(request,id=0): if (checkworkoutuser(request.user,w)): tcxfile = tpstuff.createtpworkoutdata(w) if tcxfile: - res = tpstuff.uploadactivity(r.tptoken,tcxfile, + res,reason,status_code = tpstuff.uploadactivity(r.tptoken,tcxfile, name=w.name) if res == 0: - message = "Upload to TrainingPeaks failed" + message = "Upload to TrainingPeaks failed with status code "+status_code+": "+reason w.uploadedtotp = -1 w.save() try: @@ -1817,7 +1817,6 @@ def rower_tp_token_refresh(request): r = Rower.objects.get(user=request.user) res = tpstuff.do_refresh_token( r.tprefreshtoken, - r.tptoken ) access_token = res[0] expires_in = res[1] diff --git a/rowsandall_app/settings.py b/rowsandall_app/settings.py index 5adfaafd..17b26242 100644 --- a/rowsandall_app/settings.py +++ b/rowsandall_app/settings.py @@ -246,8 +246,7 @@ UNDERARMOUR_REDIRECT_URI = "http://rowsandall.com/underarmour_callback" # TrainingPeaks TP_CLIENT_ID = CFG["tp_client_id"] TP_CLIENT_SECRET = CFG["tp_client_secret"] -TP_REDIRECT_URI = "http://rowsandall.com/tp_callback" -#TP_REDIRECT_URI = "http://localhost:8000/tp_callback" +TP_REDIRECT_URI = CFG["tp_redirect_uri"] TP_CLIENT_KEY = TP_CLIENT_ID # RQ stuff