bug fix
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user