Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2017-05-23 22:05:25 +02:00
parent f6070e985f
commit eea087f4ee
2 changed files with 34 additions and 20 deletions

View File

@@ -387,7 +387,11 @@ def sendmail(request):
def add_workout_from_strokedata(user,importid,data,strokedata,
source='c2',splitdata=None,
workoutsource='concept2'):
workouttype = data['type']
try:
workouttype = data['type']
except KeyError:
workouttype = 'rower'
if workouttype not in [x[0] for x in Workout.workouttypes]:
workouttype = 'water'
try:
@@ -6177,18 +6181,24 @@ def workout_getstravaworkout_all(request):
res = stravastuff.get_strava_workout(request.user,stravaid)
strokedata = res[1]
data = res[0]
id,message = add_workout_from_strokedata(request.user,stravaid,data,strokedata,
source='strava',
workoutsource='strava')
if id==0:
messages.error(request,message)
if data:
id,message = add_workout_from_strokedata(
request.user,stravaid,data,strokedata,
source='strava',
workoutsource='strava')
if id==0:
messages.error(request,message)
else:
messages.info(request,"imported Strava workout "+str(stravaid))
w = Workout.objects.get(id=id)
w.uploadedtostrava=stravaid
w.save()
else:
w = Workout.objects.get(id=id)
w.uploadedtostrava=stravaid
w.save()
messages.error(request,"Couldn't import Strava workout "+str(stravaid))
url = reverse(workouts_view)
return HttpResponseRedirect(url)