diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-20 16:39:48 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-20 16:39:48 +0100 |
commit | 5ee4335eb92f2dc35b31c208bce8d8e8aef9e5f2 (patch) | |
tree | a69ef6c431a6ae0fb5224d0a4c843707f01ddbcb /ctrack/organisations/views.py | |
parent | f4aa5e17544c27fcddb5d8977a3653a31bfccd4d (diff) |
added org list hard-filtered by lead inspector
Diffstat (limited to 'ctrack/organisations/views.py')
-rw-r--r-- | ctrack/organisations/views.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py index ae98305..1d1978e 100644 --- a/ctrack/organisations/views.py +++ b/ctrack/organisations/views.py @@ -1,6 +1,7 @@ import itertools from typing import Any +from django.contrib.auth import get_user_model from django.contrib.auth.mixins import PermissionRequiredMixin from django.db import transaction from django.db.models import Q @@ -28,6 +29,18 @@ def essential_service_detail(request, pk): return render(request, "organisations/essential_service_detail.html", context) +class OrganisationListViewByLeadInspector(ListView): + model = Organisation + template_name = "organisations/organisation_list.html" + + def get_context_data(self, *, object_list=None, **kwargs): + context = super().get_context_data(**kwargs) + inspector = get_user_model().objects.get(id=self.kwargs.get("id")) + context["organisation_list"] = Organisation.objects.filter(lead_inspector=inspector) + context["inspector"] = inspector + return context + + class PersonListView(PermissionRequiredMixin, ListView): model = Person template_name = "organisations/person_list.html" |