diff options
author | Matthew Lemon <y@yulqen.org> | 2024-10-16 10:06:37 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-10-16 10:06:37 +0100 |
commit | 7f7debbe0d5d5bbbe4182207137b651be100e408 (patch) | |
tree | 73eb9bd9faefb2641f997a6c3f43814d2b0b9633 | |
parent | 3c724c0a25a8cfa34befbbb88bff1236cc88ec20 (diff) |
Fixes miss-named list view function
-rw-r--r-- | engagements/templates/engagements/organisation_list.html | 79 | ||||
-rw-r--r-- | engagements/tests/test_views.py | 9 | ||||
-rw-r--r-- | engagements/urls.py | 1 | ||||
-rw-r--r-- | engagements/views.py | 4 | ||||
-rw-r--r-- | instruments/tests/test_views.py | 2 | ||||
-rw-r--r-- | instruments/views.py | 3 |
6 files changed, 96 insertions, 2 deletions
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 %} + +<div class="flex py-4"> + <div class="w-full px-4 py-8 my-5 bg-white shadow-md rounded-lg"> + <header class="bg-blue-100 p-4"> + <h2 class="text-2xl font-bold">Organisations</h2> + </header> + <div class="p-4 mb-4"> + <div class="overflow-x-auto"> + <table class="w-full divide-y divide-gray-200"> + <thead class="bg-gray-50"> + <tr> + <th scope="col" class="px-2 py-1 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Organisation</th> + <th scope="col" class="px-2 py-1 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Team</th> + <th scope="col" class="px-2 py-1 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Is Regulated?</th> + <th scope="col" class="px-2 py-1 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Responsible Persons</th> + <th scope="col" class="px-2 py-1 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Accountable Persons</th> + <th scope="col" class="px-2 py-1 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Information Holders</th> + </tr> + </thead> + <tbody class="divide-y divide-gray-200"> + {% for obj in object_list %} + <tr> + <td class="px-2 py-1 whitespace-nowrap text-m">{{ obj.name }}</td> + <td class="px-2 py-1 whitespace-nowrap text-m">{{ obj.lead_team }}</td> + <td class="text-center px-2 py-1 whitespace-nowrap text-m"> + {% if obj.is_regulated_entity %} + ✅ + {% else %} + ❌ + {% endif %} + </td> + <td class="px-2 py-1 whitespace-nowrap text-m"> + {% if obj.rp.all %} + <ul> + {% for p in obj.rp.all %} + <li>{{ p.first_name }} {{p.last_name }}</li> + {% endfor %} + </ul> + {% else %} + <p>-</p> + {% endif %} + </td> + <td class="px-2 py-1 whitespace-nowrap text-m"> + {% if obj.ap.all %} + <ul> + {% for p in obj.ap.all %} + <li>{{ p.first_name }} {{p.last_name }}</li> + {% endfor %} + </ul> + {% else %} + <p>-</p> + {% endif %} + </td> + <td class="px-2 py-1 whitespace-nowrap text-m"> + {% if p.obj.ih.all %} + <ul> + {% for p in obj.ih.all %} + <li>{{ p.first_name }} {{p.last_name }}</li> + {% endfor %} + </ul> + {% else %} + <p>-</p> + {% endif %} + </td> + </tr> + {% endfor %} + </tbody> + </table> + + </div> + + </div> + </div> +</div> + +{% 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("<int:pk>", views.engagement_detail, name="engagement_detail"), + path("org/", views.OrgListView.as_view(), name="org_detail"), path("plan/<slug:orgslug>/", 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 |