adding favorite analysis to workouts list
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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/"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user