Private
Public Access
1
0

added sync options

This commit is contained in:
Sander Roosendaal
2017-09-26 13:57:11 +02:00
parent d56a8bb74d
commit 2a4d0100d2
2 changed files with 70 additions and 4 deletions

View File

@@ -75,10 +75,12 @@ class Command(BaseCommand):
if uploadoptions and not 'error' in uploadoptions:
w = Workout.objects.get(wid[0])
r = w.user
uploads.do_sync(w,uploadoptions)
if 'make_plot' in uploadoptions:
plottype = uploadoptions['plottype']
res = uploads.make_plot(r,w,plottype,
title,f2[6:],f2)
res = uploads.make_plot(r,w,f2[6:],
w.csvfilename,
plottype,title)
try:
if wid != 1:
dd = send_confirm(rr.user,title,link,
@@ -106,10 +108,13 @@ class Command(BaseCommand):
if uploadoptions:
w = Workout.objects.get(wid[0])
r = w.user
uploads.do_sync(w,uploadoptions)
if 'make_plot' in uploadoptions:
plottype = uploadoptions['plottype']
res = uploads.make_plot(r,w,plottype,
title,f2[6:],f2)
res = uploads.make_plot(r,w,a.document,
w.csvfilename,
plottype,name)
except:
# replace with code to process error

View File

@@ -176,3 +176,64 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
i.save()
return i.id
import c2stuff,stravastuff,sporttracksstuff,runkeeperstuff
import underarmourstuff,tpstuff
def do_sync(w,options):
if 'upload_to_C2' in options and options['upload_to_C2']:
try:
message,id = c2stuff.workout_c2_upload(w.user.user,w)
except C2NoTokenError:
id = 0
message = "Something went wrong with the Concept2 sync"
if 'upload_to_Strava' in options and options['upload_to_Strava']:
try:
message,id = stravastuff.workout_strava_upload(
w.user.user,w
)
except StravaNoTokenError:
id = 0
message = "Please connect to Strava first"
if 'upload_to_SportTracks' in options and options['upload_to_SportTracks']:
try:
message,id = sporttracksstuff.workout_sporttracks_upload(
w.user.user,w
)
except SportTracksNoTokenError:
message = "Please connect to SportTracks first"
id = 0
if 'upload_to_RunKeeper' in options and options['upload_to_RunKeeper']:
try:
message,id = runkeeperstuff.workout_runkeeper_upload(
w.user.user,w
)
except RunKeeperNoTokenError:
message = "Please connect to Runkeeper first"
id = 0
if 'upload_to_MapMyFitness' in options and options['upload_to_MapMyFitness']:
try:
message,id = underarmourstuff.workout_ua_upload(
w.user.user,w
)
except UnderArmourNoTokenError:
message = "Please connect to MapMyFitness first"
id = 0
if 'upload_to_TrainingPeaks' in options and options['upload_to_TrainingPeaks']:
try:
message,id = tpstuff.workout_tp_upload(
w.user.user,w
)
except TPNoTokenError:
message = "Please connect to TrainingPeaks first"
id = 0
return 1