Private
Public Access
1
0

Merge branch 'hotfix/fitfiles'

This commit is contained in:
Sander Roosendaal
2017-02-19 09:33:59 +01:00
4 changed files with 13 additions and 5 deletions

View File

@@ -229,6 +229,7 @@ def timedeltaconv(x):
def save_workout_database(f2,r,dosmooth=True,workouttype='rower', def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
dosummary=True,title='Workout', dosummary=True,title='Workout',
notes='',totaldist=0,totaltime=0, notes='',totaldist=0,totaltime=0,
summary='',
makeprivate=False): makeprivate=False):
message = None message = None
powerperc = 100*np.array([r.pw_ut2, powerperc = 100*np.array([r.pw_ut2,
@@ -481,6 +482,7 @@ def new_workout_from_file(r,f2,
workouttype=workouttype, workouttype=workouttype,
makeprivate=makeprivate, makeprivate=makeprivate,
dosummary=dosummary, dosummary=dosummary,
summary=summary,
title=title) title=title)
return (id,message,f2) return (id,message,f2)

View File

@@ -235,14 +235,18 @@ def handle_stravaexport(f2,workoutname,stravatoken,description=''):
act = client.upload_activity(f2,'tcx',name=workoutname) act = client.upload_activity(f2,'tcx',name=workoutname)
try: try:
res = act.wait(poll_interval=5.0) res = act.wait(poll_interval=5.0)
message = 'Workout successfully synchronized to Strava'
except: except:
res = 0 res = 0
# description doesn't work yet. Have to wait for stravalib to update # description doesn't work yet. Have to wait for stravalib to update
act = client.update_activity(res.id,activity_type='Rowing',description=description) if res:
act = client.update_activity(res.id,activity_type='Rowing',description=description)
else:
message = 'Strava upload timed out.'
return res.id return (res.id,message)

View File

@@ -197,6 +197,8 @@ def create_invite(team,manager,user=None,email=''):
user = User.objects.get(rower=r2) user = User.objects.get(rower=r2)
except Rower.DoesNotExist: except Rower.DoesNotExist:
user=None user=None
except Rower.MultipleObjectsReturned:
return (0,'There is more than one user with that email address')
if count_club_members(team.manager)+count_invites(team.manager) < r.clubsize: if count_club_members(team.manager)+count_invites(team.manager) < r.clubsize:
codes = [i.code for i in TeamInvite.objects.all()] codes = [i.code for i in TeamInvite.objects.all()]

View File

@@ -803,11 +803,11 @@ def workout_strava_upload_view(request,id=0):
tcxfile = stravastuff.createstravaworkoutdata(w) tcxfile = stravastuff.createstravaworkoutdata(w)
if tcxfile: if tcxfile:
with open(tcxfile,'rb') as f: with open(tcxfile,'rb') as f:
res = stravastuff.handle_stravaexport(f,w.name, res,mes = stravastuff.handle_stravaexport(f,w.name,
r.stravatoken, r.stravatoken,
description=w.notes) description=w.notes)
if res==0: if res==0:
message = "Strava Upload error: %s" % e message = mes
w.uploadedtostrava = -1 w.uploadedtostrava = -1
w.save() w.save()
os.remove(tcxfile) os.remove(tcxfile)
@@ -823,7 +823,7 @@ def workout_strava_upload_view(request,id=0):
w.save() w.save()
os.remove(tcxfile) os.remove(tcxfile)
url = "/rowers/workout/"+str(w.id)+"/edit" url = "/rowers/workout/"+str(w.id)+"/edit"
successmessage = 'Workout sent to Strava.' successmessage = mes
except: except:
with open("media/stravaerrors.log","a") as errorlog: with open("media/stravaerrors.log","a") as errorlog:
errorstring = str(sys.exc_info()[0]) errorstring = str(sys.exc_info()[0])