From f7722ed564a54a99f3592edf21d98ba27324bcab Mon Sep 17 00:00:00 2001 From: klmp200 Date: Tue, 27 Sep 2016 16:44:12 +0200 Subject: [PATCH] Fixed permissions on stats --- counter/views.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/counter/views.py b/counter/views.py index c77c4fd3..aeca06a4 100644 --- a/counter/views.py +++ b/counter/views.py @@ -695,7 +695,7 @@ class CounterActivityView(DetailView): pk_url_kwarg = "counter_id" template_name = 'counter/activity.jinja' -class CounterStatView(DetailView): +class CounterStatView(DetailView, CanEditMixin): """ Show the bar stats """ @@ -725,13 +725,15 @@ class CounterStatView(DetailView): return kwargs def dispatch(self, request, *args, **kwargs): - res = super(CounterStatView, self).dispatch(request, *args, **kwargs) - # help(self.object) - if (request.user.is_root - or request.user.is_board_member - or self.object.is_owned_by(request.user) - ): - return res + try: + return super(CounterStatView, self).dispatch(request, *args, **kwargs) + except: + try: + if (request.user.is_root + or request.user.is_board_member + or self.object.is_owned_by(request.user)): + return super(CanEditMixin, self).dispatch(request, *args, **kwargs) + except:pass raise PermissionDenied