diff --git a/rowers/models.py b/rowers/models.py
index 827c4585..d25a36b4 100644
--- a/rowers/models.py
+++ b/rowers/models.py
@@ -136,6 +136,12 @@ class FavoriteChart(models.Model):
('finish','Finish Angle'),
('peakforceangle','Peak Force Angle'),
)
+
+ workouttypechoices = (
+ ('ote','Erg/SkiErg'),
+ ('otw','On The Water'),
+ ('both','both')
+ )
plottypes = (
('line','Line Chart'),
@@ -143,15 +149,20 @@ class FavoriteChart(models.Model):
)
yparam1 = models.CharField(max_length=50,choices=y1params,verbose_name='Y1')
- yparam2 = models.CharField(max_length=50,choices=y2params,verbose_name='Y2')
+ yparam2 = models.CharField(max_length=50,choices=y2params,verbose_name='Y2',default='None',blank=True)
xparam = models.CharField(max_length=50,choices=xparams,verbose_name='X')
- plottype = models.CharField(max_length=50,choices=plottypes,default='line')
+ plottype = models.CharField(max_length=50,choices=plottypes,
+ default='line',
+ verbose_name='Chart Type')
+ workouttype = models.CharField(max_length=50,choices=workouttypechoices,
+ default='both',
+ verbose_name='Workout Type')
user = models.ForeignKey(Rower)
class FavoriteForm(ModelForm):
class Meta:
model = FavoriteChart
- fields = ['xparam','yparam1','yparam2','plottype']
+ fields = ['xparam','yparam1','yparam2','plottype','workouttype']
class BaseFavoriteFormSet(BaseFormSet):
def clean(self):
@@ -170,6 +181,15 @@ class BaseFavoriteFormSet(BaseFormSet):
'Must have x parameter.',
code='missing_xparam'
)
+
+ if not yparam1:
+ raise forms.ValidationError(
+ 'Must have Y1 parameter.',
+ code='missing_yparam1'
+ )
+
+ if not yparam2:
+ yparam2 = 'None'
class Workout(models.Model):
workouttypes = (
diff --git a/rowers/templates/favoritecharts.html b/rowers/templates/favoritecharts.html
index 4a6406a8..f9490625 100644
--- a/rowers/templates/favoritecharts.html
+++ b/rowers/templates/favoritecharts.html
@@ -15,6 +15,9 @@
{% endfor %}
+
+
+
diff --git a/rowers/templates/flexchart3.html b/rowers/templates/flexchart3.html
index 1a023259..1a6fa8fb 100644
--- a/rowers/templates/flexchart3.html
+++ b/rowers/templates/flexchart3.html
@@ -163,6 +163,7 @@
+{% if user.rower.rowerplan == 'pro' %}
{% if maxfav >= 0 %}
@@ -193,7 +194,7 @@
{% endif %}
-
+{% endif %}
{% endblock %}
{% endlocaltime %}
diff --git a/rowers/templates/flexchart3otw.html b/rowers/templates/flexchart3otw.html
index 812361c5..d643a073 100644
--- a/rowers/templates/flexchart3otw.html
+++ b/rowers/templates/flexchart3otw.html
@@ -198,6 +198,38 @@
+{% if user.rower.rowerplan == 'pro' %}
+
+
+
+ {% if favoritenr > 0 %}
+
<
+ {% else %}
+
+ {% endif %}
+
+
+
+
+
+ {% if favoritenr < maxfav %}
+
>
+ {% else %}
+
+ {% endif %}
+
+
+{% endif %}
{% endblock %}
{% endlocaltime %}
diff --git a/rowers/views.py b/rowers/views.py
index 7869f470..d91a02a9 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -2612,7 +2612,13 @@ def workout_flexchart3_view(request,*args,**kwargs):
mayedit=1
- favorites = FavoriteChart.objects.filter(user=r).order_by("id")
+ workouttype = 'ote'
+ if row.workouttype == 'water':
+ workouttype = 'otw'
+
+
+ favorites = FavoriteChart.objects.filter(user=r,
+ workouttype__in=[workouttype,'both']).order_by("id")
maxfav = len(favorites)-1
if 'xparam' in kwargs:
@@ -2633,9 +2639,13 @@ def workout_flexchart3_view(request,*args,**kwargs):
if 'yparam2' in kwargs:
yparam2 = kwargs['yparam2']
+ if yparam2 == '':
+ yparam2 = 'None'
else:
if favorites:
yparam2 = favorites[favoritenr].yparam2
+ if yparam2 == '':
+ yparam2 = 'None'
else:
yparam2 = 'hr'
@@ -4492,18 +4502,19 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
})
-@login_required()
+@user_passes_test(promember,login_url="/login")
def rower_favoritecharts_view(request):
message = ''
successmessage = ''
r = Rower.objects.get(user=request.user)
favorites = FavoriteChart.objects.filter(user=r).order_by('id')
favorites_data = [{'yparam1':f.yparam1,
- 'yparam2':f.yparam2,
- 'xparam':f.xparam,
- 'plottype':f.plottype}
+ 'yparam2':f.yparam2,
+ 'xparam':f.xparam,
+ 'plottype':f.plottype,
+ 'workouttype':f.workouttype}
for f in favorites]
- FavoriteChartFormSet = formset_factory(FavoriteForm,formset=BaseFavoriteFormSet)
+ FavoriteChartFormSet = formset_factory(FavoriteForm,formset=BaseFavoriteFormSet,extra=0)
if request.method == 'POST':
favorites_formset = FavoriteChartFormSet(request.POST)
@@ -4515,11 +4526,13 @@ def rower_favoritecharts_view(request):
yparam2 = favorites_form.cleaned_data.get('yparam2')
xparam = favorites_form.cleaned_data.get('xparam')
plottype = favorites_form.cleaned_data.get('plottype')
+ workouttype = favorites_form.cleaned_data.get('workouttype')
new_instances.append(FavoriteChart(user=r,
yparam1=yparam1,
yparam2=yparam2,
xparam=xparam,
- plottype=plottype))
+ plottype=plottype,
+ workouttype=workouttype))
try:
with transaction.atomic():
FavoriteChart.objects.filter(user=r).delete()