From d5833c7364060076ed4af460a6f020344ce74f21 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 5 Sep 2024 15:01:16 +0100 Subject: Improved engagement detail page layout, using htmx --- .../templates/engagements/engagement_detail.html | 219 ++++++++++++++------- .../engagements/snippets/effort_detail.html | 27 +++ engagements/urls.py | 1 + engagements/views.py | 12 +- 4 files changed, 181 insertions(+), 78 deletions(-) create mode 100644 engagements/templates/engagements/snippets/effort_detail.html (limited to 'engagements') diff --git a/engagements/templates/engagements/engagement_detail.html b/engagements/templates/engagements/engagement_detail.html index c75523b..848b9f6 100644 --- a/engagements/templates/engagements/engagement_detail.html +++ b/engagements/templates/engagements/engagement_detail.html @@ -1,84 +1,96 @@ {% extends "core/base.html" %} {% load table_extras %} +{% load static %} {% block title %}{{ engagement }}{% endblock title %} {% block content %}
-
-
-

{{ engagement.friendly_type }} - at {{ engagement.external_party }}

-
-
- +
-

Details

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Date - {{ engagement.proposed_start_date|date:'l' }} - - {{ engagement.proposed_start_date|date:'j M Y' }} -
Site/Operation{{ engagement.external_party }}
Subject of Activity -

Summary text

- - - - - - - - {% for t in dscs %} - - - - {% endfor %} - -
- DSC -
- {{ t }} -
-
Inspectors{{ engagement.officers.all|commalist }}
Planned Effort{{ effort_planned|floatformat }} hrs
Actual Effort{{ effort_actual|floatformat }} hrs
Total Effort{{ effort_total|floatformat }} hrs
+
+
+
+

{{ engagement.friendly_type }} + at {{ engagement.external_party }}

+
+
+
+
+ +
+ + + + Tuesday - 10 May 2022 +
+ + +
+ + + + + + Smith, Short and Brookes +
+ + +
+ + + + + + DSC 1 - Title 1 +
+ + +
+ + + + + Hilary James, Carly Robinson, Alison Smart +
+ + +
+ + + + + Actual Effort: 5.3 hrs +
+ + + +
+
+
-
-
-

Effort for this engagement

+
+
+

Effort

+ {% endblock content %} diff --git a/engagements/templates/engagements/snippets/effort_detail.html b/engagements/templates/engagements/snippets/effort_detail.html new file mode 100644 index 0000000..16c64b4 --- /dev/null +++ b/engagements/templates/engagements/snippets/effort_detail.html @@ -0,0 +1,27 @@ +
+
+

Effort Details

+ +
+
+

Effort Details

+

Type: {{ effort.effort_type }}

+

Date: {{ effort.proposed_start_date|date:"d M Y" }}

+

Hours: {{ effort.hours }}

+

Notes: {{ effort.notes|default:"No notes available" }}

+ +
+
+ + diff --git a/engagements/urls.py b/engagements/urls.py index 7b6ddd3..ef61f84 100644 --- a/engagements/urls.py +++ b/engagements/urls.py @@ -13,6 +13,7 @@ urlpatterns = [ name="regulatedentities", ), path("edit/", views.engagement_edit, name="edit"), + path('effort//detail/', views.effort_detail, name='effort_detail'), path("create//", views.engagement_create, name="create"), path("create//", views.engagement_create, name="create"), path( diff --git a/engagements/views.py b/engagements/views.py index ae1abfd..a76a37d 100644 --- a/engagements/views.py +++ b/engagements/views.py @@ -1,11 +1,13 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.mixins import LoginRequiredMixin from django.db.models import Q -from django.shortcuts import get_object_or_404, redirect, render +from django.http import HttpResponse +from django.shortcuts import get_object_or_404 +from django.shortcuts import redirect, render +from django.template.loader import render_to_string from django.views.generic import ListView from instruments.models import SubInstrument - from .forms import ( EngagementCreateForm, EngagementEffortPlanningCreateForm, @@ -16,6 +18,12 @@ from .forms import ( from .models import Engagement, EngagementEffort, EngagementType, Organisation +def effort_detail(request, effort_id): + effort = get_object_or_404(EngagementEffort, id=effort_id) + html = render_to_string('engagements/snippets/effort_detail.html', {'effort': effort}) + return HttpResponse(html) + + class RegulatedEntitiesView(LoginRequiredMixin, ListView): context_object_name = "entities" queryset = Organisation.objects.filter(is_regulated_entity=True).order_by("name") -- cgit v1.2.3