From 51ff06faddab6c446a66337f61afd66de2f36603 Mon Sep 17 00:00:00 2001 From: arona Date: Tue, 16 May 2023 16:01:27 +0100 Subject: [PATCH] Add power record status chip, checklist status chip displays number of checklists --- RIGS/models.py | 10 +++++++++- RIGS/templates/partials/event_status.html | 14 ++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/RIGS/models.py b/RIGS/models.py index 6194079a..ccac6b4e 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -409,7 +409,15 @@ class Event(models.Model, RevisionMixin): @property def hs_done(self): - return self.riskassessment is not None and len(self.checklists.all()) > 0 + return self.riskassessment is not None and self.has_checklist and self.has_power + + @property + def has_checklist(self): + return self.checklists.exists() + + @property + def has_power(self): + return self.power_tests.exists() @property def has_start_time(self): diff --git a/RIGS/templates/partials/event_status.html b/RIGS/templates/partials/event_status.html index cb93b8d3..e4f1ad53 100644 --- a/RIGS/templates/partials/event_status.html +++ b/RIGS/templates/partials/event_status.html @@ -15,19 +15,21 @@ {% endif %} {% endif %} {% if not event.dry_hire %} - {% if event.riskassessment %} + {% if event.has_checklist %} RA: {% else %} RA: {% endif %} - {% endif %} - {% if not event.dry_hire %} - {% if event.hs_done %} - {# TODO Display status of all checklists #} - Checklist: + {% if event.has_checklist %} + Checklist: {% if event.checklists.count > 1 %}({{event.checklists.count}}){% endif %} {% else %} Checklist: {% endif %} + {% if event.has_power %} + Power Record: {% if event.power_tests.count > 1 %}({{event.power_tests.count}}){% endif %} + {% else %} + Power Record: + {% endif %} {% endif %} {% if perms.RIGS.view_invoice %} {% if event.invoice %}