fixed strava import errors
This commit is contained in:
@@ -163,9 +163,12 @@ def get_strava_workout(user,stravaid):
|
|||||||
url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/latlng?resolution="+fetchresolution
|
url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/latlng?resolution="+fetchresolution
|
||||||
latlongjson = requests.get(url,headers=headers)
|
latlongjson = requests.get(url,headers=headers)
|
||||||
|
|
||||||
|
try:
|
||||||
t = np.array(timejson.json()[0]['data'])
|
t = np.array(timejson.json()[0]['data'])
|
||||||
d = np.array(distancejson.json()[0]['data'])
|
d = np.array(distancejson.json()[0]['data'])
|
||||||
nr_rows = len(t)
|
nr_rows = len(t)
|
||||||
|
except KeyError:
|
||||||
|
return (0,"something went wrong with the Strava import")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
spm = np.array( spmjson.json()[1]['data'])
|
spm = np.array( spmjson.json()[1]['data'])
|
||||||
|
|||||||
@@ -1164,7 +1164,16 @@ def rower_process_twittercallback(request):
|
|||||||
# Process Strava Callback
|
# Process Strava Callback
|
||||||
@login_required()
|
@login_required()
|
||||||
def rower_process_stravacallback(request):
|
def rower_process_stravacallback(request):
|
||||||
|
try:
|
||||||
code = request.GET['code']
|
code = request.GET['code']
|
||||||
|
except MultiValueDictKeyError:
|
||||||
|
try:
|
||||||
|
message = request.GET['error']
|
||||||
|
except MultiValueDictKeyError:
|
||||||
|
message = "access error"
|
||||||
|
|
||||||
|
return imports_view(request,message=message)
|
||||||
|
|
||||||
res = stravastuff.get_token(code)
|
res = stravastuff.get_token(code)
|
||||||
|
|
||||||
if res[0]:
|
if res[0]:
|
||||||
@@ -4394,6 +4403,10 @@ def workout_c2import_view(request,message=""):
|
|||||||
# Import a workout from Strava
|
# Import a workout from Strava
|
||||||
@login_required()
|
@login_required()
|
||||||
def workout_getstravaworkout_view(request,stravaid):
|
def workout_getstravaworkout_view(request,stravaid):
|
||||||
|
res = stravastuff.get_strava_workout(request.user,stravaid)
|
||||||
|
if not res[0]:
|
||||||
|
message = "Something went wrong in Strava import"
|
||||||
|
return imports_view(request,message=message)
|
||||||
|
|
||||||
strokedata = res[1]
|
strokedata = res[1]
|
||||||
data = res[0]
|
data = res[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user