From 7f7debbe0d5d5bbbe4182207137b651be100e408 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 16 Oct 2024 10:06:37 +0100 Subject: Fixes miss-named list view function --- .../templates/engagements/organisation_list.html | 79 ++++++++++++++++++++++ engagements/tests/test_views.py | 9 +++ engagements/urls.py | 1 + engagements/views.py | 4 ++ instruments/tests/test_views.py | 2 +- instruments/views.py | 3 +- 6 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 engagements/templates/engagements/organisation_list.html diff --git a/engagements/templates/engagements/organisation_list.html b/engagements/templates/engagements/organisation_list.html new file mode 100644 index 0000000..4328067 --- /dev/null +++ b/engagements/templates/engagements/organisation_list.html @@ -0,0 +1,79 @@ +{% extends "core/base.html" %} + +{% block content %} + +
+
+
+

Organisations

+
+
+
+ + + + + + + + + + + + + {% for obj in object_list %} + + + + + + + + + {% endfor %} + +
OrganisationTeamIs Regulated?Responsible PersonsAccountable PersonsInformation Holders
{{ obj.name }}{{ obj.lead_team }} + {% if obj.is_regulated_entity %} + ✅ + {% else %} + ❌ + {% endif %} + + {% if obj.rp.all %} +
    + {% for p in obj.rp.all %} +
  • {{ p.first_name }} {{p.last_name }}
  • + {% endfor %} +
+ {% else %} +

-

+ {% endif %} +
+ {% if obj.ap.all %} +
    + {% for p in obj.ap.all %} +
  • {{ p.first_name }} {{p.last_name }}
  • + {% endfor %} +
+ {% else %} +

-

+ {% endif %} +
+ {% if p.obj.ih.all %} +
    + {% for p in obj.ih.all %} +
  • {{ p.first_name }} {{p.last_name }}
  • + {% endfor %} +
+ {% else %} +

-

+ {% endif %} +
+ +
+ +
+
+
+ +{% endblock content %} diff --git a/engagements/tests/test_views.py b/engagements/tests/test_views.py index 01d73c7..a7a420b 100644 --- a/engagements/tests/test_views.py +++ b/engagements/tests/test_views.py @@ -19,6 +19,7 @@ def test_single_day_string(): duration_str = duration_formatter(d1, d2) assert duration_str == "10 October 2024 (1 day)" + def test_multi_duration_string(): """test date formatting for the summary box on the detail page""" d1 = datetime.date(2024, 10, 10) @@ -26,6 +27,7 @@ def test_multi_duration_string(): duration_str = duration_formatter(d1, d2) assert duration_str == "10-12 October 2024 (3 days)" + def test_multi_duration_string_longer(): """test date formatting for the summary box on the detail page""" d1 = datetime.date(2024, 10, 1) @@ -33,6 +35,7 @@ def test_multi_duration_string_longer(): duration_str = duration_formatter(d1, d2) assert duration_str == "01-12 October 2024 (12 days)" + def test_multi_duration_over_month_boundary_string(): """test date formatting for the summary box on the detail page""" d1 = datetime.date(2024, 9, 30) @@ -131,3 +134,9 @@ def test_create_engagement_strategy(client, user, org, regulatory_cycles): # Check that the response redirects (status code 302) after successful creation assert response.status_code == 302 assert EngagementStrategy.objects.count() == 1 + + +def test_org_list_page_exists(client): + url = reverse("engagements:org_detail") + response = client.get(url) + assert response.status_code == 302 diff --git a/engagements/urls.py b/engagements/urls.py index a199b34..3f3c9ae 100644 --- a/engagements/urls.py +++ b/engagements/urls.py @@ -6,6 +6,7 @@ app_name = "engagements" urlpatterns = [ path("", views.engagement_planning, name="home"), path("", views.engagement_detail, name="engagement_detail"), + path("org/", views.OrgListView.as_view(), name="org_detail"), path("plan//", views.engagement_plan_for, name="plan_for_org"), path( "regulatedentities/", diff --git a/engagements/views.py b/engagements/views.py index 6d7d4c9..7146b67 100644 --- a/engagements/views.py +++ b/engagements/views.py @@ -205,3 +205,7 @@ class CreateEngagementStrategy(LoginRequiredMixin, CreateView): form_class = EngagementStrategyCreateForm template_name = "engagements/engagement_strategy_form.html" success_url = reverse_lazy("engagements:home") + + +class OrgListView(LoginRequiredMixin, ListView): + model = Organisation diff --git a/instruments/tests/test_views.py b/instruments/tests/test_views.py index 048ab47..e1573a2 100644 --- a/instruments/tests/test_views.py +++ b/instruments/tests/test_views.py @@ -7,4 +7,4 @@ pytestmark = pytest.mark.django_db def test_view_url_exists_at_desired_location(client): url = reverse("instruments:sop-list") response = client.get(url) - assert response.status_code == 200 + assert response.status_code == 302 diff --git a/instruments/views.py b/instruments/views.py index 0329e00..37ec69f 100644 --- a/instruments/views.py +++ b/instruments/views.py @@ -1,10 +1,11 @@ # from django.shortcuts import render +from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic.list import ListView from .models import SOP -class SOPListView(ListView): +class SOPListView(LoginRequiredMixin, ListView): model = SOP paginate_by = 100 -- cgit v1.2.3