Private
Public Access
1
0

favorite charts by workout source

This commit is contained in:
Sander Roosendaal
2018-10-26 09:17:19 +02:00
parent 4e0db6e2e0
commit d85a1a7045
6 changed files with 47 additions and 27 deletions

View File

@@ -751,11 +751,14 @@ parchoicesx = list(sorted(favchartlabelsx.items(), key = lambda x:x[1]))
# Saving a chart as a favorite chart # Saving a chart as a favorite chart
class FavoriteChart(models.Model): class FavoriteChart(models.Model):
workouttypechoices = ( workouttypechoices = [
('ote','Erg/SkiErg'), ('ote','Erg/SkiErg'),
('otw','On The Water'), ('otw','On The Water'),
('both','both') ('all','All')
) ]
for workoutsource in mytypes.workoutsources:
workouttypechoices.append(workoutsource)
plottypes = ( plottypes = (
('line','Line Chart'), ('line','Line Chart'),
@@ -771,6 +774,7 @@ class FavoriteChart(models.Model):
workouttype = models.CharField(max_length=50,choices=workouttypechoices, workouttype = models.CharField(max_length=50,choices=workouttypechoices,
default='both', default='both',
verbose_name='Workout Type') verbose_name='Workout Type')
reststrokes = models.BooleanField(default=True,verbose_name="Incl. Rest") reststrokes = models.BooleanField(default=True,verbose_name="Incl. Rest")
notes = models.CharField(max_length=300,verbose_name='Chart Notes', notes = models.CharField(max_length=300,verbose_name='Chart Notes',
default='Flex Chart Notes',blank=True) default='Flex Chart Notes',blank=True)

View File

@@ -30,14 +30,14 @@ workoutsources = (
('mapmyfitness','mapmyfitness'), ('mapmyfitness','mapmyfitness'),
('csv','painsled'), ('csv','painsled'),
('tcx','tcx'), ('tcx','tcx'),
('rp','rp'), ('rp','rowperfect'),
('mystery','mystery'), ('mystery','mystery'),
('tcxnohr','tcx (no HR)'), # ('tcxnohr','tcx (no HR)'),
('rowperfect3','rowperfect3'), ('rowperfect3','rowperfect3'),
('ergdata','ergdata'), ('ergdata','ergdata'),
('boatcoach','boatcoach'), ('boatcoach','boatcoach'),
('boatcoachotw','boatcoachotw'), ('boatcoachotw','boatcoachotw'),
('bcmike','boatcoach (develop)'), # ('bcmike','boatcoach (develop)'),
('painsleddesktop','painsleddesktop'), ('painsleddesktop','painsleddesktop'),
('speedcoach','speedcoach'), ('speedcoach','speedcoach'),
('speedcoach2','speedcoach2'), ('speedcoach2','speedcoach2'),
@@ -52,6 +52,7 @@ boattypes = (
('2-', '2- (pair)'), ('2-', '2- (pair)'),
('2+', '2+ (coxed pair)'), ('2+', '2+ (coxed pair)'),
('3x+','3x+ (coxed triple)'), ('3x+','3x+ (coxed triple)'),
('3x-','3x- (triple)'),
('4x', '4x (quad)'), ('4x', '4x (quad)'),
('4x+', '4x+ (coxed quad)'), ('4x+', '4x+ (coxed quad)'),
('4-', '4- (four)'), ('4-', '4- (four)'),

View File

@@ -74,7 +74,9 @@ $('#id_workouttype').change();
</tr><tr> </tr><tr>
<th>Duration:</th><td>{{ workout.duration |durationprint:"%H:%M:%S.%f" }}</td> <th>Duration:</th><td>{{ workout.duration |durationprint:"%H:%M:%S.%f" }}</td>
</tr><tr> </tr><tr>
<th>Public link to this workout</th> <th>Source:</th><td>{{ workout.workoutsource }}</td>
</tr><tr>
<th>Public link to this workout:</th>
<td> <td>
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a> <a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
</td> </td>

View File

@@ -26,7 +26,7 @@ queue = django_rq.get_queue('default')
queuelow = django_rq.get_queue('low') queuelow = django_rq.get_queue('low')
queuehigh = django_rq.get_queue('low') queuehigh = django_rq.get_queue('low')
from mytypes import workouttypes,boattypes,otwtypes from mytypes import workouttypes,boattypes,otwtypes,workoutsources
try: try:
from cStringIO import StringIO from cStringIO import StringIO

View File

@@ -8755,6 +8755,34 @@ def workout_workflow_config2_view(request,userid=0):
}) })
def getfavorites(r,row):
workouttype = 'ote'
if row.workouttype in mytypes.otwtypes:
workouttype = 'otw'
matchworkouttypes = [workouttype,'all']
workoutsource = row.workoutsource
if 'speedcoach2' in row.workoutsource:
workoutsource = 'speedcoach2'
try:
favorites = FavoriteChart.objects.filter(user=r,
workouttype__in=matchworkouttypes).order_by("id")
favorites2 = FavoriteChart.objects.filter(user=r,
workouttype__in=[workoutsource]).order_by("id")
favorites = favorites | favorites2
maxfav = len(favorites)-1
except:
favorites = None
maxfav = 0
return favorites,maxfav
# Workflow View # Workflow View
@login_required() @login_required()
def workout_workflow_view(request,id): def workout_workflow_view(request,id):
@@ -8774,17 +8802,8 @@ def workout_workflow_view(request,id):
aantalcomments = len(comments) aantalcomments = len(comments)
workouttype = 'ote' favorites,maxfav = getfavorites(r,row)
if row.workouttype in mytypes.otwtypes:
workouttype = 'otw'
try:
favorites = FavoriteChart.objects.filter(user=r,
workouttype__in=[workouttype,'both']).order_by("id")
maxfav = len(favorites)-1
except:
favorites = None
maxfav = 0
charts = get_call() charts = get_call()
@@ -8889,13 +8908,7 @@ def workout_flexchart3_view(request,*args,**kwargs):
if row.workouttype in mytypes.otwtypes: if row.workouttype in mytypes.otwtypes:
workouttype = 'otw' workouttype = 'otw'
try: favorites,maxfav = getfavorites(r,row)
favorites = FavoriteChart.objects.filter(user=r,
workouttype__in=[workouttype,'both']).order_by("id")
maxfav = len(favorites)-1
except:
favorites = None
maxfav = 0
# check if favoritenr is not out of range # check if favoritenr is not out of range
if favorites: if favorites:

View File

@@ -149,7 +149,7 @@
</li> </li>
{% if user.is_authenticated %} {% if user.is_authenticated %}
<li> <li>
<a href="/rowers/me/edit" title="Profile"> <a href="/rowers/me/preferences" title="Profile">
{% if user.rower.rowerplan == 'pro' %} {% if user.rower.rowerplan == 'pro' %}
<i class="fas fa-user-ninja "></i> <i class="fas fa-user-ninja "></i>
{% elif user.rower.rowerplan == 'coach' %} {% elif user.rower.rowerplan == 'coach' %}