diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index 2c2589ce..ad119f8f 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -4392,6 +4392,7 @@ def workout_toggle_ranking(request,id=0): # simple POST API for files on local (e.g. in mailbox) @csrf_exempt def workout_upload_api(request): + stravaid = 0 if request.method != 'POST': message = {'status':'false','message':'this view cannot be accessed through GET'} return JSONResponse(status=403,data=message) @@ -4441,6 +4442,11 @@ def workout_upload_api(request): message = {'status':'false','message':'could not find file'} return JSONResponse(status=400,data=message) + try: + stravaid = post_data['stravaid'] + except KeyError: + stravaid = 0 + if form.is_valid(): t = form.cleaned_data['title'] boattype = form.cleaned_data['boattype'] @@ -4491,6 +4497,10 @@ def workout_upload_api(request): return JSONResponse(status=400,data=message) w = Workout.objects.get(id=id) + if stravaid != 0: + w.uploadedtostrava = stravaid + w.save() + if make_plot: res, jobid = uploads.make_plot(r,w,f1,f2,plottype,t) @@ -4501,7 +4511,7 @@ def workout_upload_api(request): except NoTokenError: pass - if upload_to_strava: + if upload_to_strava and stravaid == 0: try: message,id = stravastuff.workout_strava_upload(r.user,w) except NoTokenError: