diff --git a/rowers/views.py b/rowers/views.py index 21edf7e7..a6cda5e9 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -958,7 +958,11 @@ def add_workout_from_strokedata(user,importid,data,strokedata, dist2 = 0.1*strokedata.ix[:,'d'] - spm = strokedata.ix[:,'spm'] + try: + spm = strokedata.ix[:,'spm'] + except KeyError: + spm = 0*dist2 + try: hr = strokedata.ix[:,'hr'] except KeyError: @@ -8961,14 +8965,17 @@ def workout_getc2workout_all(request,page=1,message=""): if res2.status_code == 200: strokedata = pd.DataFrame.from_dict(res2.json()['data']) # create the workout - id,message = add_workout_from_strokedata( - request.user,c2id,data,strokedata, - source='c2') - w = Workout.objects.get(id=id) - w.uploadedtoc2=c2id - w.save() - if message: - messages.error(request,message) + try: + id,message = add_workout_from_strokedata( + request.user,c2id,data,strokedata, + source='c2') + w = Workout.objects.get(id=id) + w.uploadedtoc2=c2id + w.save() + if message: + messages.error(request,message) + except KeyError: + pass url = reverse(workouts_view) return HttpResponseRedirect(url)