aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ctrack/organisations/templates/organisations/organisation_list.html29
-rw-r--r--ctrack/organisations/tests/test_views.py26
-rw-r--r--ctrack/organisations/urls.py3
-rw-r--r--ctrack/organisations/views.py14
4 files changed, 59 insertions, 13 deletions
diff --git a/ctrack/organisations/templates/organisations/organisation_list.html b/ctrack/organisations/templates/organisations/organisation_list.html
index 8e7b72a..dfce156 100644
--- a/ctrack/organisations/templates/organisations/organisation_list.html
+++ b/ctrack/organisations/templates/organisations/organisation_list.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% load static %}
-{% block title %} Organisations{% endblock %}
+{% block title %}Organisations/OES{% endblock %}
{% block content %}
@@ -25,14 +25,17 @@
<path fill-rule="evenodd"
d="M7 14s-1 0-1-1 1-4 5-4 5 3 5 4-1 1-1 1H7zm4-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-5.784 6A2.238 2.238 0 0 1 5 13c0-1.355.68-2.75 1.936-3.72A6.325 6.325 0 0 0 5 9c-4 0-5 3-5 4s1 1 1 1h4.216zM4.5 8a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5z"/>
</svg>
- {% if inspector %}
- Organisations (Lead inspector: {{ inspector.name }})
+ {% if inspector and is_oes %}
+ OES (Lead inspector: {{ inspector.name }})
+ {% elif is_oes %}
+ OES
{% else %}
Organisations
{% endif %}
</h3>
<span><a href="{% url "organisations:create" %}">[Create new...]</a></span></h3>
- <p>Use the search box to filter the table. The table can be exported in various formats using the buttons below. These
+ <p>Use the search box to filter the table. The table can be exported in various formats using the buttons below.
+ These
downloads will respect the filtering used.</p>
<div class="row justify-content-center">
<div class="col-md-12 my-2 py-2">
@@ -44,17 +47,20 @@
<th>Lead Inspector</th>
<th>Deputy Lead Inspector</th>
<th>Point of Contact</th>
+ <th>OES</th>
</tr>
</thead>
{% for org in organisation_list %}
<tr>
<td><a href="{% url "organisations:detail" org.slug %}">{{ org.name }}</a></td>
<td>{{ org.submode }}</td>
- {% if org.lead_inspector %}
- <td><a href="{% url "organisations:list_by_inspector" org.lead_inspector.pk %}">{{ org.lead_inspector.name }}</a></td>
- {% else %}
- <td>{{ org.lead_inspector.name }}</td>
- {% endif %}
+ {% if org.lead_inspector %}
+ <td>
+ <a href="{% url "organisations:list_by_inspector" org.lead_inspector.pk %}">{{ org.lead_inspector.name }}</a>
+ </td>
+ {% else %}
+ <td>{{ org.lead_inspector.name }}</td>
+ {% endif %}
<td>{{ org.deputy_lead_inspector.name }}</td>
<td>
{% if org.primary_contacts %}
@@ -67,6 +73,11 @@
No contact listed
{% endif %}
</td>
+ {% if org.oes is True %}
+ <td>Yes</td>
+ {% else %}
+ <td>No</td>
+ {% endif %}
</tr>
{% endfor %}
</table>
diff --git a/ctrack/organisations/tests/test_views.py b/ctrack/organisations/tests/test_views.py
index e1b31fb..c939894 100644
--- a/ctrack/organisations/tests/test_views.py
+++ b/ctrack/organisations/tests/test_views.py
@@ -9,7 +9,7 @@ from ctrack.organisations.tests.factories import (
OrganisationFactory,
SingleDateTimeEventFactory,
)
-from ctrack.organisations.views import IncidentReportCreateView, OrganisationDetailView
+from ctrack.organisations.views import IncidentReportCreateView, OrganisationDetailView, oes_list
from ..utils import filter_private_events
from ..views import OrganisationListView
@@ -49,7 +49,6 @@ def test_meetings_in_organisation_detail_view(user, client, org_with_people):
assert "First Meeting" in html
-
def test_private_event_filter(user, org_with_people):
"""
In this test we are creating five events, using two different users.
@@ -206,6 +205,29 @@ def test_organisation_list_view():
assert len(response.context_data["organisation_list"]) == 3
+def test_oes_list_view():
+ OrganisationFactory.create(oes=True)
+ OrganisationFactory.create(oes=True)
+ OrganisationFactory.create(oes=True)
+
+ factory = RequestFactory()
+ user = get_user_model().objects.create_user(
+ username="testy", email="testy@test.com", password="test1020"
+ )
+ # This user needs permission to acccess the list view
+ org_list_permission = Permission.objects.get(name="Can view organisation")
+ assert user.user_permissions.count() == 0
+ user.user_permissions.add(org_list_permission)
+ assert user.has_perm("organisations.view_organisation")
+ user.save()
+ request = factory.get("/organisations/oes")
+ request.user = user
+ response = oes_list(request)
+ assert response.status_code == 200
+ html = response.content.decode("utf-8")
+ assert "OES" in html
+
+
def test_only_member_of_cct_user_group_can_view_org_list():
OrganisationFactory.create()
OrganisationFactory.create()
diff --git a/ctrack/organisations/urls.py b/ctrack/organisations/urls.py
index 33a741c..6001ccd 100644
--- a/ctrack/organisations/urls.py
+++ b/ctrack/organisations/urls.py
@@ -7,12 +7,13 @@ from ctrack.organisations.views import (
OrganisationListView,
PersonListView,
essential_service_detail,
- person_detail, OrganisationListViewByLeadInspector,
+ person_detail, OrganisationListViewByLeadInspector, oes_list,
)
app_name = "organisations"
urlpatterns = [
+ path("oes/", oes_list, name="list_oes"),
path("people/", view=PersonListView.as_view(), name="people"),
path("<slug:slug>/", view=OrganisationDetailView.as_view(), name="detail"),
path(
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py
index 1d1978e..5726aa2 100644
--- a/ctrack/organisations/views.py
+++ b/ctrack/organisations/views.py
@@ -36,8 +36,11 @@ class OrganisationListViewByLeadInspector(ListView):
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["organisation_list"] = Organisation.objects.filter(
+ lead_inspector=inspector, oes=True
+ )
context["inspector"] = inspector
+ context["is_oes"] = True
return context
@@ -52,6 +55,15 @@ def person_detail(request, person_id):
return render(request, "organisations/person_detail.html", {"person": p})
+def oes_list(request):
+ oes = Organisation.objects.filter(oes=True)
+ return render(
+ request,
+ "organisations/organisation_list.html",
+ {"organisation_list": oes, "is_oes": True},
+ )
+
+
class OrganisationCreate(PermissionRequiredMixin, CreateView):
model = Organisation
template_name = "organisations/org_create_formset.html"