Private
Public Access
1
0

added OTW and workouttype to favoritechart model

This commit is contained in:
Sander Roosendaal
2016-12-07 18:12:38 +01:00
parent bfc05a7de6
commit 84c3b7e175
5 changed files with 82 additions and 11 deletions

View File

@@ -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()