mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 22:23:23 +00:00
Protect stats from other users
This commit is contained in:
parent
dfd465c7f9
commit
63506b1506
@ -262,6 +262,14 @@ class UserStatsView(UserTabsMixin, CanViewMixin, DetailView):
|
|||||||
template_name = "core/user_stats.jinja"
|
template_name = "core/user_stats.jinja"
|
||||||
current_tab = 'stats'
|
current_tab = 'stats'
|
||||||
|
|
||||||
|
def dispatch(self, request, *arg, **kwargs):
|
||||||
|
profile = self.get_object()
|
||||||
|
|
||||||
|
if (profile != request.user and not request.user.is_root):
|
||||||
|
raise PermissionDenied
|
||||||
|
|
||||||
|
return super(UserStatsView, self).dispatch(request, *arg, **kwargs)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super(UserStatsView, self).get_context_data(**kwargs)
|
kwargs = super(UserStatsView, self).get_context_data(**kwargs)
|
||||||
from counter.models import Counter, Product, Selling
|
from counter.models import Counter, Product, Selling
|
||||||
|
Loading…
Reference in New Issue
Block a user