diff --git a/rowers/models.py b/rowers/models.py index 371331f5..cd626d7b 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -157,6 +157,38 @@ class Rower(models.Model): ('hwt','heavy-weight'), ('lwt','light-weight'), ) + + stravatypes = ( + ('Ride','Ride'), + ('Kitesurf','Kitesurf'), + ('Run','Run'), + ('NordicSki','NordicSki'), + ('Swim','Swim'), + ('RockClimbing','RockClimbing'), + ('Hike','Hike'), + ('RollerSki','RollerSki'), + ('Walk','Walk'), + ('Rowing','Rowing'), + ('AlpineSki','AlpineSki'), + ('Snowboard','Snowboard'), + ('BackcountrySki','BackcountrySki'), + ('Snowshoe','Snowshoe'), + ('Canoeing','Canoeing'), + ('StairStepper','StairStepper'), + ('Crossfit','Crossfit'), + ('StandUpPaddling','StandUpPaddling'), + ('EBikeRide','EBikeRide'), + ('Surfing','Surfing'), + ('Elliptical','Elliptical'), + ('VirtualRide','VirtualRide'), + ('IceSkate','IceSkate'), + ('WeightTraining','WeightTraining'), + ('InlineSkate','InlineSkate'), + ('Windsurf','Windsurf'), + ('Kayaking','Kayaking'), + ('Workout','Workout'), + ('Yoga','Yoga'), + ) user = models.OneToOneField(User) # Heart Rate Zone data @@ -215,6 +247,10 @@ class Rower(models.Model): blank=True,null=True) stravatoken = models.CharField(default='',max_length=200,blank=True,null=True) + stravaexportas = models.CharField(default="Rowing", + max_length=30, + choices=stravatypes, + verbose_name="Export Workouts to Strava as") runkeepertoken = models.CharField(default='',max_length=200, blank=True,null=True) @@ -558,6 +594,11 @@ class AdvancedWorkoutForm(ModelForm): model = Workout fields = ['boattype','weightvalue'] +class RowerExportForm(ModelForm): + class Meta: + model = Rower + fields = ['stravaexportas'] + # Simple form to set rower's Functional Threshold Power class RowerPowerForm(ModelForm): class Meta: diff --git a/rowers/stravastuff.py b/rowers/stravastuff.py index cf9378ed..c41dfa64 100644 --- a/rowers/stravastuff.py +++ b/rowers/stravastuff.py @@ -276,7 +276,8 @@ def createstravaworkoutdata(w,dozip=True): # Upload the TCX file to Strava and set the workout activity type # to rowing on Strava -def handle_stravaexport(f2,workoutname,stravatoken,description=''): +def handle_stravaexport(f2,workoutname,stravatoken,description='', + activity_type='Rowing'): # w = Workout.objects.get(id=workoutid) client = stravalib.Client(access_token=stravatoken) @@ -291,7 +292,7 @@ def handle_stravaexport(f2,workoutname,stravatoken,description=''): # description doesn't work yet. Have to wait for stravalib to update if res: - act = client.update_activity(res.id,activity_type='Rowing',description=description,device_name='Rowsandall.com') + act = client.update_activity(res.id,activity_type=activity_type,description=description,device_name='Rowsandall.com') else: message = 'Strava activity update timed out.' return (0,message) diff --git a/rowers/templates/export.html b/rowers/templates/export.html index 3953b013..6ccd0bb6 100644 --- a/rowers/templates/export.html +++ b/rowers/templates/export.html @@ -188,6 +188,15 @@
+ + diff --git a/rowers/templates/rower_exportsettings.html b/rowers/templates/rower_exportsettings.html new file mode 100644 index 00000000..fbaa80e2 --- /dev/null +++ b/rowers/templates/rower_exportsettings.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} + +{% block title %}Change Rower Export Settings{% endblock %} + +{% block content %} ++
+ Please correct the error{{ form.errors|pluralize }} below. +
+ {% endif %} + +