From 8156034ae190c9f5abc404ac3f63ae4922117924 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 10 Aug 2017 09:52:53 +0200 Subject: [PATCH] initial modality form --- rowers/forms.py | 33 +++++-------- rowers/models.py | 53 +++------------------ rowers/templates/user_multiflex_select.html | 46 +++++++++++++----- rowers/types.py | 47 ++++++++++++++++++ rowers/views.py | 4 ++ 5 files changed, 101 insertions(+), 82 deletions(-) create mode 100644 rowers/types.py diff --git a/rowers/forms.py b/rowers/forms.py index e64014aa..910b6ce5 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -8,7 +8,7 @@ from django.forms.extras.widgets import SelectDateWidget from django.utils import timezone,translation from django.forms import ModelForm import dataprep - +import types import datetime # login form @@ -45,18 +45,6 @@ class StrokeDataForm(forms.Form): # The form used for uploading files class DocumentsForm(forms.Form): - filetypechoices = ( - ('csv' , 'Painsled iOS CSV'), - ('tcx' , 'TCX'), - ('tcxnohr' , 'TCX No HR'), - ('rp' , 'RowPro CSV'), - ('speedcoach' , 'SpeedCoach GPS CSV'), - ('speedcoach2' , 'SpeedCoach GPS 2 CSV'), - ('ergdata' , 'ErgData CSV'), - ('ergstick' , 'ErgStick CSV'), - ('painsleddesktop' , 'Painsled Desktop CSV'), - ('zip','Zipped file'), - ) title = forms.CharField(required=False) file = forms.FileField(required=True, validators=[validate_file_extension]) @@ -275,15 +263,17 @@ class IntervalUpdateForm(forms.Form): self.fields['type_%s' % i].widget.attrs['style'] = 'width:156px; height: 22px;' self.fields['intervald_%s' % i].widget = forms.TimeInput(format='%H:%M:%S.%f') -boattypes = ( - ('1x', '1x (single)'), - ('2x', '2x (double)'), - ('2-', '2- (pair)'), - ('4x', '4x (quad)'), - ('4-', '4- (four)'), - ('8+', '8+ (eight)'), -) +boattypes = types.boattypes +workouttypes = types.workouttypes +# form to select modality and boat type for trend flex +class TrendFlexModalForm(forms.Form): + modality = forms.ChoiceField(choices=workouttypes, + label='Workout Type') + waterboattype = forms.MultipleChoiceField(choices=boattypes, + label='Water Boat Type', + initial = ['1x','2x','2-','4x','4-','8+']) + # This form sets options for the summary stats page class StatsOptionsForm(forms.Form): @@ -342,7 +332,6 @@ formaxlabelsmultiflex['workoutid'] = 'Workout' parchoicesmultiflex = list(sorted(formaxlabelsmultiflex.items(), key = lambda x:x[1])) from utils import palettes -#palettechoices = { key:key for key, value in palettes.iteritems() } palettechoices = tuple((p,p) for p in palettes.keys()) diff --git a/rowers/models.py b/rowers/models.py index e880ca24..011eb585 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -22,6 +22,8 @@ import datetime from django.core.exceptions import ValidationError from rowers.rows import validate_file_extension +import types + from rowsandall_app.settings import ( TWEET_ACCESS_TOKEN_KEY, TWEET_ACCESS_TOKEN_SECRET, @@ -353,53 +355,10 @@ def checkworkoutuser(user,workout): # Workout class Workout(models.Model): - workouttypes = ( - ('water','On-water'), - ('rower','Indoor Rower'), - ('skierg','Ski Erg'), - ('dynamic','Dynamic Indoor Rower'), - ('slides','Indoor Rower on Slides'), - ('paddle','Paddle Adapter'), - ('snow','On-snow'), - ('coastal','Coastal'), - ('other','Other'), - ) - - workoutsources = ( - ('strava','strava'), - ('concept2','concept2'), - ('sporttracks','sporttracks'), - ('runkeeper','runkeeper'), - ('mapmyfitness','mapmyfitness'), - ('csv','painsled'), - ('tcx','tcx'), - ('rp','rp'), - ('mystery','mystery'), - ('tcxnohr','tcx (no HR)'), - ('rowperfect3','rowperfect3'), - ('ergdata','ergdata'), - ('boatcoach','boatcoach'), - ('bcmike','boatcoach (develop)'), - ('painsleddesktop','painsleddesktop'), - ('speedcoach','speedcoach'), - ('speedcoach2','speedcoach2'), - ('ergstick','ergstick'), - ('fit','fit'), - ('unknown','unknown')) - - boattypes = ( - ('1x', '1x (single)'), - ('2x', '2x (double)'), - ('2-', '2- (pair)'), - ('4x', '4x (quad)'), - ('4-', '4- (four)'), - ('8+', '8+ (eight)'), - ) - - privacychoices = ( - ('private','Private'), - ('visible','Visible'), - ) + workouttypes = types.workouttypes + workoutsources = types.workoutsources + boattypes = types.boattypes + privacychoices = types.privacychoices user = models.ForeignKey(Rower) team = models.ManyToManyField(Team,blank=True) diff --git a/rowers/templates/user_multiflex_select.html b/rowers/templates/user_multiflex_select.html index 0b0b8642..06db28ce 100644 --- a/rowers/templates/user_multiflex_select.html +++ b/rowers/templates/user_multiflex_select.html @@ -45,22 +45,42 @@
-
- +
{% if theuser %}
- {% else %} - - {% endif %} - - - {{ dateform.as_table }} -
- {% csrf_token %} -
-
- + {% else %} +
+ {% endif %} +
+ + + {{ dateform.as_table }} +
+ {% csrf_token %} +
+
+ +
+
+ {% if theuser %} +
+ {% else %} + + {% endif %} +
+ + + {{ modalityform.as_table }} +
+ {% csrf_token %} +
+
+ +
+
+ +
diff --git a/rowers/types.py b/rowers/types.py new file mode 100644 index 00000000..0dc8244e --- /dev/null +++ b/rowers/types.py @@ -0,0 +1,47 @@ +workouttypes = ( + ('water','On-water'), + ('rower','Indoor Rower'), + ('skierg','Ski Erg'), + ('dynamic','Dynamic Indoor Rower'), + ('slides','Indoor Rower on Slides'), + ('paddle','Paddle Adapter'), + ('snow','On-snow'), + ('coastal','Coastal'), + ('other','Other'), +) + +workoutsources = ( + ('strava','strava'), + ('concept2','concept2'), + ('sporttracks','sporttracks'), + ('runkeeper','runkeeper'), + ('mapmyfitness','mapmyfitness'), + ('csv','painsled'), + ('tcx','tcx'), + ('rp','rp'), + ('mystery','mystery'), + ('tcxnohr','tcx (no HR)'), + ('rowperfect3','rowperfect3'), + ('ergdata','ergdata'), + ('boatcoach','boatcoach'), + ('bcmike','boatcoach (develop)'), + ('painsleddesktop','painsleddesktop'), + ('speedcoach','speedcoach'), + ('speedcoach2','speedcoach2'), + ('ergstick','ergstick'), + ('fit','fit'), + ('unknown','unknown')) + +boattypes = ( + ('1x', '1x (single)'), + ('2x', '2x (double)'), + ('2-', '2- (pair)'), + ('4x', '4x (quad)'), + ('4-', '4- (four)'), + ('8+', '8+ (eight)'), +) + +privacychoices = ( + ('private','Private'), + ('visible','Visible'), +) diff --git a/rowers/views.py b/rowers/views.py index d7afd580..6dd967da 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -36,6 +36,7 @@ from rowers.forms import ( RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm, UpdateStreamForm,WorkoutMultipleCompareForm,ChartParamChoiceForm, FusionMetricChoiceForm,BoxPlotChoiceForm,MultiFlexChoiceForm, + TrendFlexModalForm, ) from rowers.models import Workout, User, Rower, WorkoutForm,FavoriteChart from rowers.models import ( @@ -3432,6 +3433,8 @@ def user_multiflex_select(request, 'includereststrokes':includereststrokes, }) + modalityform = TrendFlexModalForm() + messages.info(request,successmessage) messages.error(request,message) @@ -3448,6 +3451,7 @@ def user_multiflex_select(request, 'theuser':user, 'form':form, 'chartform':chartform, + 'modalityform':modalityform, 'teams':get_my_teams(request.user), })