From f6248947f69cad84bc0de137c8ead91f4cedbfd6 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 4 Nov 2020 18:54:08 +0100 Subject: [PATCH 1/3] adding fav_analysis and 2 forms to change it --- rowers/models.py | 17 ++++++++++++++++- rowers/views/userviews.py | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/rowers/models.py b/rowers/models.py index 43c2c3ff..dee8372b 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -977,6 +977,20 @@ class Rower(models.Model): slowpaceotw = models.DurationField(default=otwpaceslow,verbose_name='Slowest OTW Pace') fastpaceotw = models.DurationField(default=otwpacefast,verbose_name='Fastest OTW Pace') + favanalysischoices = ( + ('compare','Compare'), + ('flexall','Cumulative Flex Chart'), + ('histogram','Histogram'), + ('stats','Statistics'), + ('boxplot','Box Chart'), + ('trendflex','Trend Flex'), + ('cp','Critical Power'), + ) + + fav_analysis = models.CharField(default='compare',choices=favanalysischoices, + max_length=100, + verbose_name='Favorite Analysis') + staticchartonupload = models.CharField(default='None',choices=plotchoices, max_length=100, verbose_name='Generate a static chart automatically on upload') @@ -3763,6 +3777,7 @@ class AccountRowerForm(ModelForm): 'getemailnotifications', 'getimportantemails', 'defaulttimezone','showfavoritechartnotes', + 'fav_analysis', 'defaultlandingpage', 'offercoaching','autojoin','emailalternatives'] @@ -3802,7 +3817,7 @@ class AccountRowerForm(ModelForm): class StaticChartRowerForm(ModelForm): class Meta: model = Rower - fields = ['staticgrids','slowpaceerg','fastpaceerg','slowpaceotw','fastpaceotw','staticchartonupload'] + fields = ['staticgrids','slowpaceerg','fastpaceerg','slowpaceotw','fastpaceotw','staticchartonupload','fav_analysis'] def __init__(self, *args, **kwargs): super(StaticChartRowerForm, self).__init__(*args, **kwargs) diff --git a/rowers/views/userviews.py b/rowers/views/userviews.py index d43c8234..031a7bba 100644 --- a/rowers/views/userviews.py +++ b/rowers/views/userviews.py @@ -246,6 +246,7 @@ def rower_favoritecharts_view(request,userid=0): r.slowpaceotw = staticchartform.cleaned_data.get('slowpaceotw') r.fastpaceotw = staticchartform.cleaned_data.get('fastpaceotw') r.staticchartonupload = staticchartform.cleaned_data.get('staticchartonupload') + r.fav_analysis = staticchartform.cleaned_data.get('fav_analysis') r.save() if request.method == 'POST' and 'form-TOTAL_FORMS' in request.POST: From dde791374cdc76154e85714d445e6931ff124856 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 4 Nov 2020 19:12:19 +0100 Subject: [PATCH 2/3] adding favorite analysis to workouts list --- rowers/models.py | 20 +++++++++---------- rowers/templates/list_workouts.html | 7 +++++++ rowers/templatetags/rowerfilters.py | 31 ++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/rowers/models.py b/rowers/models.py index dee8372b..1e6e9e00 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -74,6 +74,16 @@ timezones = ( (x,x) for x in pytz.common_timezones ) +favanalysischoices = ( + ('compare','Compare'), + ('flexall','Cumulative Flex Chart'), + ('histogram','Histogram'), + ('stats','Statistics'), + ('boxplot','Box Chart'), + ('trendflex','Trend Flex'), + ('cp','Critical Power'), +) + def half_year_from_now(): return (datetime.datetime.now(tz=timezone.utc)+timezone.timedelta(days=182)).date() @@ -977,16 +987,6 @@ class Rower(models.Model): slowpaceotw = models.DurationField(default=otwpaceslow,verbose_name='Slowest OTW Pace') fastpaceotw = models.DurationField(default=otwpacefast,verbose_name='Fastest OTW Pace') - favanalysischoices = ( - ('compare','Compare'), - ('flexall','Cumulative Flex Chart'), - ('histogram','Histogram'), - ('stats','Statistics'), - ('boxplot','Box Chart'), - ('trendflex','Trend Flex'), - ('cp','Critical Power'), - ) - fav_analysis = models.CharField(default='compare',choices=favanalysischoices, max_length=100, verbose_name='Favorite Analysis') diff --git a/rowers/templates/list_workouts.html b/rowers/templates/list_workouts.html index 4a603cc0..69b39d1f 100644 --- a/rowers/templates/list_workouts.html +++ b/rowers/templates/list_workouts.html @@ -242,6 +242,13 @@   {% endif %} + + + + + Date: Wed, 4 Nov 2020 19:16:38 +0100 Subject: [PATCH 3/3] fixing test --- rowers/tests/test_user.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rowers/tests/test_user.py b/rowers/tests/test_user.py index 92cff5e1..3199249b 100644 --- a/rowers/tests/test_user.py +++ b/rowers/tests/test_user.py @@ -113,6 +113,7 @@ class UserPreferencesTest(TestCase): 'getimportantemails':True, 'defaulttimezone':'UTC', 'showfavoritechartnotes':False, + 'fav_analysis':'compare', 'defaultlandingpage':'workout_edit_view', 'first_name': self.u.first_name, 'last_name': self.u.last_name,