Merge branch 'release/v11.22'
This commit is contained in:
@@ -439,15 +439,19 @@ def createstravaworkoutdata(w,dozip=True):
|
||||
# Upload the TCX file to Strava and set the workout activity type
|
||||
# to rowing on Strava
|
||||
def handle_stravaexport(f2,workoutname,stravatoken,description='',
|
||||
activity_type='Rowing'):
|
||||
activity_type='Rowing',async=False):
|
||||
# w = Workout.objects.get(id=workoutid)
|
||||
client = stravalib.Client(access_token=stravatoken)
|
||||
|
||||
act = client.upload_activity(f2,'tcx.gz',name=workoutname)
|
||||
|
||||
try:
|
||||
res = act.wait(poll_interval=5.0,timeout=30)
|
||||
message = 'Workout successfully synchronized to Strava'
|
||||
if async:
|
||||
res = act.wait(poll_interval=1.0, timeout=10)
|
||||
message = 'Workout successfully synchronized to Strava'
|
||||
else:
|
||||
res = act.wait(poll_interval=5.0,timeout=30)
|
||||
message = 'Workout successfully synchronized to Strava'
|
||||
except:
|
||||
res = 0
|
||||
message = 'Strava upload timed out'
|
||||
@@ -621,7 +625,7 @@ def add_workout_from_data(user,importid,data,strokedata,
|
||||
|
||||
return id,message
|
||||
|
||||
def workout_strava_upload(user,w):
|
||||
def workout_strava_upload(user,w, async=False):
|
||||
try:
|
||||
thetoken = strava_open(user)
|
||||
except NoTokenError:
|
||||
@@ -644,7 +648,7 @@ def workout_strava_upload(user,w):
|
||||
f,w.name,
|
||||
r.stravatoken,
|
||||
description=w.notes+'\n from '+w.workoutsource+' via rowsandall.com',
|
||||
activity_type=r.stravaexportas)
|
||||
activity_type=r.stravaexportas,async=async)
|
||||
if res==0:
|
||||
message = mes
|
||||
w.uploadedtostrava = -1
|
||||
|
||||
@@ -507,7 +507,7 @@ def make_private(w,options):
|
||||
|
||||
return 1
|
||||
|
||||
def do_sync(w,options):
|
||||
def do_sync(w,options, async=False):
|
||||
try:
|
||||
upload_to_strava = options['upload_to_Strava']
|
||||
except KeyError:
|
||||
@@ -532,7 +532,7 @@ def do_sync(w,options):
|
||||
if ('upload_to_Strava' in options and upload_to_strava) or (w.user.strava_auto_export and ispromember(w.user.user)):
|
||||
try:
|
||||
message,id = stravastuff.workout_strava_upload(
|
||||
w.user.user,w
|
||||
w.user.user,w,async=async
|
||||
)
|
||||
except NoTokenError:
|
||||
id = 0
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
from rowers.views.statements import *
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Export workout to TCX and send to user's email address
|
||||
@permission_required('workout.change_workout',fn=get_workout_by_opaqueid,raise_exception=True)
|
||||
def workout_tcxemail_view(request,id=0):
|
||||
|
||||
@@ -105,7 +105,7 @@ def workout_strava_upload_view(request,id=0):
|
||||
f,w.name,
|
||||
r.stravatoken,
|
||||
description=newnotes,
|
||||
activity_type=activity_type)
|
||||
activity_type=activity_type,async=True)
|
||||
if res==0:
|
||||
messages.error(request,mes)
|
||||
w.uploadedtostrava = -1
|
||||
|
||||
@@ -4500,7 +4500,7 @@ def workout_upload_api(request):
|
||||
|
||||
w = Workout.objects.get(id=id)
|
||||
|
||||
uploads.do_sync(w,post_data)
|
||||
uploads.do_sync(w,post_data,async=True)
|
||||
|
||||
if make_plot:
|
||||
res, jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
|
||||
|
||||
Reference in New Issue
Block a user