From 945e521febfbc8be35dc80444f116f8f61643a99 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Mon, 31 Aug 2020 13:45:32 +0100 Subject: [PATCH] Do event table color logic at python level --- RIGS/models.py | 16 +++++++++++++++- RIGS/templates/event_table.html | 2 +- RIGS/templates/partials/event_table_colour.html | 11 ----------- RIGS/templates/partials/hs_status.html | 4 ++-- 4 files changed, 18 insertions(+), 15 deletions(-) delete mode 100644 RIGS/templates/partials/event_table_colour.html diff --git a/RIGS/models.py b/RIGS/models.py index 09c68890..c628e1d8 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -378,7 +378,10 @@ class Event(models.Model, RevisionMixin): @property def authorised(self): - return not self.internal and self.purchase_order or self.authorisation.amount == self.total + if self.internal: + return self.authorisation.amount == self.total + else: + return bool(self.purchase_order) @property def has_start_time(self): @@ -444,6 +447,17 @@ class Event(models.Model, RevisionMixin): def internal(self): return self.organisation and self.organisation.union_account + @property + def status_color(self): + if self.cancelled: + return "text-muted table-secondary" + elif not self.is_rig: + return "table-info" + elif self.authorised and self.mic and (self.dry_hire or self.riskassessment): + return "table-success" + else: + return "table-warning" + objects = EventManager() def get_absolute_url(self): diff --git a/RIGS/templates/event_table.html b/RIGS/templates/event_table.html index d00207b2..29ed0e54 100644 --- a/RIGS/templates/event_table.html +++ b/RIGS/templates/event_table.html @@ -12,7 +12,7 @@ {% for event in events %} - + {{ event.display_id }} diff --git a/RIGS/templates/partials/event_table_colour.html b/RIGS/templates/partials/event_table_colour.html deleted file mode 100644 index be9faae7..00000000 --- a/RIGS/templates/partials/event_table_colour.html +++ /dev/null @@ -1,11 +0,0 @@ -class="{% if event.cancelled %} - text-muted table-secondary - {% elif event.dry_hire and event.authorised and event.mic %} - table-success - {% elif event.authorised and event.risk_assessment_edit_url and event.mic %} - table-success - {% elif not event.is_rig %} - table-info - {% else %} - table-warning - {% endif %}" diff --git a/RIGS/templates/partials/hs_status.html b/RIGS/templates/partials/hs_status.html index ae6e2068..2d88a1b4 100644 --- a/RIGS/templates/partials/hs_status.html +++ b/RIGS/templates/partials/hs_status.html @@ -2,8 +2,8 @@ {% if object.pk != None %} {# Completed
#}
- - + +
{{ object.review_string|safe }} {% else %}