Private
Public Access
1
0

Pro metrics restricted to Pro users

When I opened Favorite Flex CHarts to all, I overlooked that this was
opening a back door to Basic users to get to view the Pro metrics.
Corrected that now. When a Favorite Flex chart with Pro metrics is
loaded, for Basic users, the values are replaced with time (x),
pace (y1) and spm (y2)
This commit is contained in:
Sander Roosendaal
2017-10-23 20:10:46 +02:00
parent 74e924a3c1
commit b7e9fbaa45
2 changed files with 14 additions and 3 deletions

View File

@@ -2046,7 +2046,6 @@ def interactive_flex_chart2(id=0,promember=0,
plottype='line',
workstrokesonly=False):
#rowdata,row = dataprep.getrowdata_db(id=id)
columns = [xparam,yparam1,yparam2,
'ftime','distance','fpace',

View File

@@ -6197,6 +6197,19 @@ def workout_flexchart3_view(request,*args,**kwargs):
else:
workstrokesonly = False
if not promember:
for name,d in rowingmetrics:
if d['type'] != 'basic':
if xparam == name:
xparam = 'time'
messages.info(request,'To use '+d['verbose_name']+', you have to be Pro member')
if yparam1 == name:
yparam1 = 'pace'
messages.info(request,'To use '+d['verbose_name']+', you have to be Pro member')
if yparam2 == name:
yparam2 = 'spm'
messages.info(request,'To use '+d['verbose_name']+', you have to be Pro member')
# create interactive plot
try:
script,div,js_resources,css_resources,workstrokesonly = interactive_flex_chart2(id,xparam=xparam,yparam1=yparam1,
@@ -8539,10 +8552,10 @@ def rower_favoritecharts_view(request):
if request.method == 'POST':
favorites_formset = FavoriteChartFormSet(request.POST)
if favorites_formset.is_valid():
new_instances = []
for favorites_form in favorites_formset:
print 'mies'
yparam1 = favorites_form.cleaned_data.get('yparam1')
yparam2 = favorites_form.cleaned_data.get('yparam2')
xparam = favorites_form.cleaned_data.get('xparam')
@@ -8568,7 +8581,6 @@ def rower_favoritecharts_view(request):
except IntegrityError:
message = "something went wrong"
messages.error(request,message)
else:
favorites_formset = FavoriteChartFormSet(initial=favorites_data)