Private
Public Access
1
0

Merge branch 'feature/favanalysis' into develop

This commit is contained in:
Sander Roosendaal
2020-11-04 19:16:48 +01:00
5 changed files with 55 additions and 2 deletions
+16 -1
View File
@@ -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,6 +987,10 @@ class Rower(models.Model):
slowpaceotw = models.DurationField(default=otwpaceslow,verbose_name='Slowest OTW Pace')
fastpaceotw = models.DurationField(default=otwpacefast,verbose_name='Fastest OTW Pace')
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)
+7
View File
@@ -242,6 +242,13 @@
 
{% endif %}
</td>
<td>
<a class="small"
href="/rowers/user-analysis-select/{{ user.rower.fav_analysis }}/workout/{{ workout.id|encode }}/"
title="{{ user.rower.fav_analysis|verbose }}">
<i class="fas {{ user.rower.fav_analysis|icon }} fa-fw"></i>
</a>
</td>
<td>
<a class="small"
href="/rowers/workout/{{ workout.id|encode }}/flexchart/"
+30 -1
View File
@@ -13,7 +13,7 @@ from rowers.models import (
course_length,WorkoutComment,
TrainingMacroCycle,TrainingMesoCycle, TrainingMicroCycle,
Rower,Workout,SiteAnnouncement, TeamInvite, TeamRequest, CoachOffer,CoachRequest,
VirtualRaceFollower,VirtualRace,
VirtualRaceFollower,VirtualRace,favanalysischoices
)
from rowers.plannedsessions import (
race_can_register, race_can_submit,race_rower_status
@@ -56,6 +56,35 @@ def isfollower(user,id):
return followers.count()==0
favanalysisdict = {}
for key,value in favanalysischoices:
favanalysisdict[key] = value
favanalysisicons = {
'compare':'fa-balance-scale',
'stats':'fa-table',
'boxplot':'fa-box-open',
'trendflex':'fa-chart-line',
'histogram':'fa-chart-bar',
'flexall':'fa-chart-line',
'cp':'fa-user-chart',
}
# for verbose version of fav analysis
@register.filter
def verbose(s):
try:
return favanalysisdict[s]
except KeyError:
return ''
@register.filter
def icon(s):
try:
return favanalysisicons[s]
except KeyError:
return 'fa-chart-line'
@register.filter
def adaptive(s):
u = s
+1
View File
@@ -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,
+1
View File
@@ -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: