diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-27 17:07:18 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-27 17:07:18 +0100 |
commit | d2ae7679000b6299c408d34f88a1c5c66755288c (patch) | |
tree | b275e48697be74ed15e8d43bab2dafa88ae21137 /ctrack/organisations/views.py | |
parent | fa674ad70439cea0de962b87e5ac4c4dc0fa16f7 (diff) |
need to fix permission denied 403 tests
Diffstat (limited to 'ctrack/organisations/views.py')
-rw-r--r-- | ctrack/organisations/views.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py index 7a1d105..1bccd3e 100644 --- a/ctrack/organisations/views.py +++ b/ctrack/organisations/views.py @@ -1,6 +1,10 @@ from typing import Any, Dict -from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin +from django.contrib.auth.mixins import ( + LoginRequiredMixin, + PermissionRequiredMixin, + UserPassesTestMixin, +) from django.db import transaction from django.urls import reverse_lazy from django.views.generic import CreateView, DetailView, ListView @@ -37,10 +41,11 @@ class OrganisationCreate(LoginRequiredMixin, CreateView): return reverse_lazy("organisations:detail", kwargs={"slug": self.object.slug}) -class OrganisationListView(PermissionRequiredMixin, LoginRequiredMixin, ListView): +class OrganisationListView(LoginRequiredMixin, UserPassesTestMixin, ListView): model = Organisation - raise_exeption = True - permission_denied_message = "Sorry. You are not authorised to view that page." + + def test_func(self): + return self.request.user.is_staff def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) |