diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 7df1d228..d09dea9e 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -71,6 +71,8 @@ def c2_open(user): else: if (timezone.now()>r.tokenexpirydate): res = rower_c2_token_refresh(user) + if res == None: + raise C2NoTokenError("User has no token") if res[0] != None: thetoken = res[0] else: @@ -311,9 +313,12 @@ def createc2workoutdata(w): except ValueError: durationstr = datetime.strptime(str(w.duration),"%H:%M:%S") - + workouttype = w.workouttype + if workouttype in ('coastal','other'): + workouttype = 'water' + data = { - "type": w.workouttype, + "type": workouttype, "date": w.startdatetime.isoformat(), "timezone": "Etc/UTC", "distance": int(w.distance), @@ -595,7 +600,8 @@ def workout_c2_upload(user,w): c2id = 0 else: - message = "You are not authorized to upload this workout to Concept2" + print response.status_code + message = "Something went wrong in workout_c2_upload_view. Response code 200/201 but C2 sync failed: "+response.text c2id = 0 return message,c2id diff --git a/rowers/forms.py b/rowers/forms.py index abbf3863..0566c38c 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -285,6 +285,7 @@ class StatsOptionsForm(forms.Form): skierg = forms.BooleanField(initial=False,required=False) paddle = forms.BooleanField(initial=False,required=False) snow = forms.BooleanField(initial=False,required=False) + coastal = forms.BooleanField(initial=False,required=False) other = forms.BooleanField(initial=False,required=False) class WorkoutMultipleCompareForm(forms.Form):