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',
dosummary=True,title='Workout',
notes='',totaldist=0,totaltime=0,
summary='',
makeprivate=False):
message = None
powerperc = 100*np.array([r.pw_ut2,
@@ -481,6 +482,7 @@ def new_workout_from_file(r,f2,
workouttype=workouttype,
makeprivate=makeprivate,
dosummary=dosummary,
summary=summary,
title=title)
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)
try:
res = act.wait(poll_interval=5.0)
message = 'Workout successfully synchronized to Strava'
except:
res = 0
# 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)
except Rower.DoesNotExist:
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:
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)
if tcxfile:
with open(tcxfile,'rb') as f:
res = stravastuff.handle_stravaexport(f,w.name,
res,mes = stravastuff.handle_stravaexport(f,w.name,
r.stravatoken,
description=w.notes)
if res==0:
message = "Strava Upload error: %s" % e
message = mes
w.uploadedtostrava = -1
w.save()
os.remove(tcxfile)
@@ -823,7 +823,7 @@ def workout_strava_upload_view(request,id=0):
w.save()
os.remove(tcxfile)
url = "/rowers/workout/"+str(w.id)+"/edit"
successmessage = 'Workout sent to Strava.'
successmessage = mes
except:
with open("media/stravaerrors.log","a") as errorlog:
errorstring = str(sys.exc_info()[0])