diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-17 14:46:23 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-17 14:46:23 +0100 |
commit | c1a64fc08f7e21c5c0933f09c665ff5a25dd8868 (patch) | |
tree | c729e128233070125280dcf550f86dbc59d06088 /ctrack | |
parent | 59592232da815f4e8c6f61cb9042e738990c1b6e (diff) |
replaced all LoginRequiredMixin and decorators with custom middleware
Diffstat (limited to '')
-rw-r--r-- | ctrack/caf/views.py | 10 | ||||
-rw-r--r-- | ctrack/core/views.py | 1 | ||||
-rw-r--r-- | ctrack/organisations/views.py | 10 | ||||
-rw-r--r-- | ctrack/register/views.py | 6 | ||||
-rw-r--r-- | ctrack/users/views.py | 6 |
5 files changed, 15 insertions, 18 deletions
diff --git a/ctrack/caf/views.py b/ctrack/caf/views.py index f748b49..a5d9953 100644 --- a/ctrack/caf/views.py +++ b/ctrack/caf/views.py @@ -11,13 +11,12 @@ from ctrack.caf.models import CAF, ApplicableSystem from ctrack.organisations.models import Organisation -class ListCAF(LoginRequiredMixin, PermissionRequiredMixin, ListView): +class ListCAF(PermissionRequiredMixin, ListView): model = CAF permission_required = "caf.view_caf" # Let's write a traditional function view! -@login_required() @permission_required("caf.view_caf") def caf_detail_view(request, pk): caf = CAF.objects.get(pk=pk) @@ -39,7 +38,7 @@ def caf_detail_view(request, pk): return render(request, "caf/caf_detail.html", context) -class ListApplicableSystem(LoginRequiredMixin, PermissionRequiredMixin, ListView): +class ListApplicableSystem(PermissionRequiredMixin, ListView): model = ApplicableSystem # apparently you can pass a list of model objects to a template if you name it # here - otherwise you need to provide a QuerySet @@ -55,7 +54,7 @@ class ListApplicableSystem(LoginRequiredMixin, PermissionRequiredMixin, ListView return context -class ApplicableSystemDetail(LoginRequiredMixin, PermissionRequiredMixin, DetailView): +class ApplicableSystemDetail(PermissionRequiredMixin, DetailView): model = ApplicableSystem template_name = "caf/applicablesystem_detail.html" permission_required = "caf.view_applicablesystem" @@ -88,8 +87,7 @@ def applicable_system_create_from_caf(request, caf_id): ) -class ApplicableSystemCreateFromOrg( - LoginRequiredMixin, PermissionRequiredMixin, FormView +class ApplicableSystemCreateFromOrg(PermissionRequiredMixin, FormView ): form_class = ApplicableSystemCreateFromOrgForm template_name = "caf/applicable_system_create_from_org.html" diff --git a/ctrack/core/views.py b/ctrack/core/views.py index d7efe34..a40f945 100644 --- a/ctrack/core/views.py +++ b/ctrack/core/views.py @@ -5,7 +5,6 @@ from ctrack.organisations.models import IncidentReport, Organisation from ctrack.register.models import EngagementEvent -@login_required def home_page(request): if request.user.is_stakeholder: org = Organisation.objects.get( diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py index c56c106..adb3b81 100644 --- a/ctrack/organisations/views.py +++ b/ctrack/organisations/views.py @@ -25,7 +25,7 @@ def essential_service_detail(request, pk): return render(request, "organisations/essential_service_detail.html", context) -class PersonListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): +class PersonListView(PermissionRequiredMixin, ListView): model = Person template_name = "organisations/person_list.html" permission_required = "organisations.view_person" @@ -36,7 +36,7 @@ def person_detail(request, person_id): return render(request, "organisations/person_detail.html", {"person": p}) -class OrganisationCreate(LoginRequiredMixin, PermissionRequiredMixin, CreateView): +class OrganisationCreate(PermissionRequiredMixin, CreateView): model = Organisation template_name = "organisations/org_create_formset.html" form_class = OrganisationCreateForm @@ -65,7 +65,7 @@ class OrganisationCreate(LoginRequiredMixin, PermissionRequiredMixin, CreateView return reverse_lazy("organisations:detail", kwargs={"slug": self.object.slug}) -class OrganisationListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): +class OrganisationListView(PermissionRequiredMixin, ListView): model = Organisation permission_required = "organisations.view_organisation" @@ -75,7 +75,7 @@ class OrganisationListView(LoginRequiredMixin, PermissionRequiredMixin, ListView return context -class OrganisationDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView): +class OrganisationDetailView(PermissionRequiredMixin, DetailView): model = Organisation permission_required = "organisations.view_organisation" @@ -109,7 +109,7 @@ class OrganisationDetailView(LoginRequiredMixin, PermissionRequiredMixin, Detail return context -class IncidentReportCreateView(LoginRequiredMixin, FormView): +class IncidentReportCreateView(FormView): model = IncidentReport form_class = IncidentReportForm template_name = "organisations/incidentreport_form.html" diff --git a/ctrack/register/views.py b/ctrack/register/views.py index 3363fcd..0ab71c3 100644 --- a/ctrack/register/views.py +++ b/ctrack/register/views.py @@ -17,7 +17,7 @@ class EngagementEventDelete(DeleteView): return reverse_lazy("organisations:detail", args=[self.kwargs["slug"]]) -class EngagementEventCreate(LoginRequiredMixin, FormView): +class EngagementEventCreate(FormView): fields = "__all__" form_class = EngagementEventCreateForm template_name = "register/engagementevent_form.html" @@ -45,7 +45,7 @@ class EngagementEventCreate(LoginRequiredMixin, FormView): return reverse_lazy("organisations:detail", args=[self.kwargs["slug"]]) -class EngagementEventCreateFromCaf(LoginRequiredMixin, FormView): +class EngagementEventCreateFromCaf(FormView): fields = "__all__" form_class = EngagementEventCreateForm template_name = "snippets/event_form_base.html" @@ -72,7 +72,7 @@ class EngagementEventCreateFromCaf(LoginRequiredMixin, FormView): return reverse_lazy("organisations:detail", args=[org_slug]) -class SingleDateTimeEventCreate(LoginRequiredMixin, FormView): +class SingleDateTimeEventCreate(FormView): template_name = "single_datetime_event_create.html" form_class = CreateSimpleDateTimeEventForm success_url = reverse_lazy("organisations:list") diff --git a/ctrack/users/views.py b/ctrack/users/views.py index 8e504e4..883cfb5 100644 --- a/ctrack/users/views.py +++ b/ctrack/users/views.py @@ -8,7 +8,7 @@ from django.views.generic import DetailView, RedirectView, UpdateView User = get_user_model() -class UserDetailView(LoginRequiredMixin, DetailView): +class UserDetailView(DetailView): model = User @@ -24,7 +24,7 @@ class UserDetailView(LoginRequiredMixin, DetailView): user_detail_view = UserDetailView.as_view() -class UserUpdateView(LoginRequiredMixin, UpdateView): +class UserUpdateView(UpdateView): model = User fields = ["name", "first_name", "last_name"] @@ -45,7 +45,7 @@ class UserUpdateView(LoginRequiredMixin, UpdateView): user_update_view = UserUpdateView.as_view() -class UserRedirectView(LoginRequiredMixin, RedirectView): +class UserRedirectView(RedirectView): permanent = False |