From 1fceffc29352d91cf98f2f452efe784a591c441d Mon Sep 17 00:00:00 2001 From: kdeterme Date: Mon, 17 Aug 2026 14:57:28 +0200 Subject: [PATCH] feat: add inspection cancellation functionality with automatic asset compliance state recalculation --- loko/assets/static/assets/inspection_map.js | 6 +- .../assets/components/asset_inspections.html | 69 ++++++- loko/inspections/admin.py | 17 ++ .../0007_alter_inspection_result_status.py | 18 ++ loko/inspections/models.py | 179 +++++++++++++----- .../components/inspection_form_modal.html | 2 + .../inspections/inspections_list.html | 78 +++++++- loko/inspections/tests.py | 117 ++++++++++++ loko/inspections/urls.py | 1 + loko/inspections/views.py | 54 +++++- 10 files changed, 481 insertions(+), 60 deletions(-) create mode 100644 loko/inspections/migrations/0007_alter_inspection_result_status.py diff --git a/loko/assets/static/assets/inspection_map.js b/loko/assets/static/assets/inspection_map.js index e10d2f1..1e61c50 100644 --- a/loko/assets/static/assets/inspection_map.js +++ b/loko/assets/static/assets/inspection_map.js @@ -322,6 +322,7 @@ 'non_compliant', '#fd7e14', 'damaged', '#dc3545', 'missing', '#212529', + 'cancelled', '#6c757d', '#6c757d' ], 'circle-stroke-width': 2, @@ -380,10 +381,11 @@ `; inspectionsList.forEach((insp, index) => { + const isCancelled = insp.is_cancelled || (insp.result_status === 'cancelled'); html += ` -
+
- ${escapeHtml(insp.result_status_display || '')} + ${escapeHtml(insp.result_status_display || '')} ${escapeHtml(insp.date || '')} diff --git a/loko/assets/templates/assets/components/asset_inspections.html b/loko/assets/templates/assets/components/asset_inspections.html index cf93ca8..a440c95 100644 --- a/loko/assets/templates/assets/components/asset_inspections.html +++ b/loko/assets/templates/assets/components/asset_inspections.html @@ -40,7 +40,7 @@ {% for insp in inspections %} - + {{ insp.inspection_date|date:"d/m/Y H:i" }} @@ -91,6 +91,14 @@