From 30d2bf6d91e625d08c38800d1b1819d90dfe7f1e Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 20 Oct 2020 15:57:26 +0100 Subject: poor implementation of lead and deputy inspectors by submode on home page --- ctrack/core/tests/test_views.py | 2 +- ctrack/core/views.py | 5 +++++ ctrack/organisations/admin.py | 8 +++++++- .../templates/organisations/organisation_list.html | 2 +- ctrack/organisations/utils.py | 23 ++++++++++++++++++++++ ctrack/organisations/views.py | 22 ++------------------- ctrack/templates/pages/home.html | 22 ++++++++++++++++----- 7 files changed, 56 insertions(+), 28 deletions(-) diff --git a/ctrack/core/tests/test_views.py b/ctrack/core/tests/test_views.py index 9f7d292..dde7b81 100644 --- a/ctrack/core/tests/test_views.py +++ b/ctrack/core/tests/test_views.py @@ -1,7 +1,7 @@ import pytest from ctrack.organisations.models import Organisation, Submode, Mode -from ctrack.organisations.views import inspectors_for_each_mode +from ctrack.organisations.utils import inspectors_for_each_mode from ctrack.organisations.tests.factories import OrganisationFactory pytestmark = pytest.mark.django_db diff --git a/ctrack/core/views.py b/ctrack/core/views.py index 499aedd..5268f66 100644 --- a/ctrack/core/views.py +++ b/ctrack/core/views.py @@ -3,6 +3,7 @@ from django.shortcuts import render from ctrack.caf.models import EssentialService, CAF, ApplicableSystem from ctrack.organisations.models import IncidentReport, Organisation, Person, Submode +from ctrack.organisations.utils import inspectors_for_each_mode from ctrack.register.models import EngagementEvent @@ -33,6 +34,8 @@ def home_page(request): no_essential_services = EssentialService.objects.count() no_systems = ApplicableSystem.objects.count() submodes = Submode.objects.all().order_by("descriptor") + submode_inspector_dict = inspectors_for_each_mode("lead_inspector") + submode_deputy_inspector_dict = inspectors_for_each_mode("deputy_lead_inspector") context = { "no_orgs": no_orgs, "no_people": no_people, @@ -41,5 +44,7 @@ def home_page(request): "no_systems": no_systems, "caf_users": caf_users, "submodes": submodes, + "submode_inspector_dict": submode_inspector_dict, + "submode_deputy_inspector_dict": submode_deputy_inspector_dict, } return render(request, "pages/home.html", context) diff --git a/ctrack/organisations/admin.py b/ctrack/organisations/admin.py index 02b02ef..5cb5bb4 100644 --- a/ctrack/organisations/admin.py +++ b/ctrack/organisations/admin.py @@ -55,7 +55,13 @@ class EssentialServiceInline(admin.StackedInline): class OrganisationAdmin(admin.ModelAdmin): inlines = [AddressInLine, EssentialServiceInline] - list_display = ("name", "submode", "date_updated") + list_display = ( + "name", + "submode", + "date_updated", + "lead_inspector", + "deputy_lead_inspector", + ) class PersonAdmin(admin.ModelAdmin): diff --git a/ctrack/organisations/templates/organisations/organisation_list.html b/ctrack/organisations/templates/organisations/organisation_list.html index 3464308..a45cae8 100644 --- a/ctrack/organisations/templates/organisations/organisation_list.html +++ b/ctrack/organisations/templates/organisations/organisation_list.html @@ -45,7 +45,7 @@ {{ org.name }} {{ org.submode }} - {{ org.lead_inspector }} + {{ org.lead_inspector.name }} {% if org.primary_contacts %}