mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-25 01:12:16 +00:00
Do event table color logic at python level
This commit is contained in:
@@ -378,7 +378,10 @@ class Event(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def authorised(self):
|
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
|
@property
|
||||||
def has_start_time(self):
|
def has_start_time(self):
|
||||||
@@ -444,6 +447,17 @@ class Event(models.Model, RevisionMixin):
|
|||||||
def internal(self):
|
def internal(self):
|
||||||
return self.organisation and self.organisation.union_account
|
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()
|
objects = EventManager()
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for event in events %}
|
{% for event in events %}
|
||||||
<tr {% include 'partials/event_table_colour.html' %} id="event_row">
|
<tr class="{{event.status_color}}" id="event_row">
|
||||||
<!---Number-->
|
<!---Number-->
|
||||||
<th scope="row" id="event_number">{{ event.display_id }}</th>
|
<th scope="row" id="event_number">{{ event.display_id }}</th>
|
||||||
<!--Dates-->
|
<!--Dates-->
|
||||||
|
|||||||
@@ -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 %}"
|
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
{% if object.pk != None %}
|
{% if object.pk != None %}
|
||||||
{#<span class="badge badge-success my-3"><span class="fas fa-check"></span> Completed</span><br/>#}
|
{#<span class="badge badge-success my-3"><span class="fas fa-check"></span> Completed</span><br/>#}
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<a href="{% url view object.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> <span class="hidden-xs">View</span>
|
<a href="{% url view object.pk %}" class="btn btn-primary"><span class="fas fa-eye"></span> <span class="hidden-xs"> View</span>
|
||||||
<a href="{% url edit object.pk %}" class="btn btn-warning"><span class="fas fa-edit"></span><span class="hidden-xs">Edit</span></a>
|
<a href="{% url edit object.pk %}" class="btn btn-warning"><span class="fas fa-edit"></span><span class="hidden-xs"> Edit</span></a>
|
||||||
</div>
|
</div>
|
||||||
{{ object.review_string|safe }}
|
{{ object.review_string|safe }}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
Reference in New Issue
Block a user