Change job status calculation

master
Pete Ley 3 weeks ago
parent 7c8ea8f7a8
commit b9cee70e45

@ -318,14 +318,26 @@ class Job(models.Model):
return q.filter(takeoff__blocks__has_any_keys=filter_appids)
return q
def is_in_design(self):
return any([xmtl.status() == 'In Design' for xmtl in self.transmittal_set.all()])
def is_in_fab(self):
return any([stair.in_fab() for sub in self.submittal_set.all() for stair in sub.stair_set.all()])
def is_at_engineering(self):
return any([xmtl.status() == 'Engineering' for xmtl in self.transmittal_set.all()])
def is_at_submittal(self):
return any([xmtl.status() == 'Submitted' for xmtl in self.transmittal_set.all()])
def status_color(self):
if self.stairs_in_design():
if self.is_in_design():
return 'blue'
if self.stairs_in_fab():
if self.is_in_fab():
return 'red'
if self.stairs_at_engineering():
if self.is_at_engineering():
return 'green'
if self.stairs_at_submittal():
if self.is_at_submittal():
return 'orange'
return 'initial'
@ -651,13 +663,30 @@ class Stair(models.Model):
else:
return any([xmtl.status() == status for xmtl in self.transmittal_set.all()])
def has_open_calendar_slots(self):
if not self.stairs_na() and (not self.stair_fabs or not self.stairs_shop):
return True
if not self.landings_na() and (not self.land_fabs or not self.lands_shop):
return True
if not self.rails_na() and (not self.rail_fabs or not self.rails_shop):
return True
if not self.embeds_na and not self.embeds_shop:
return True
return False
@display(boolean=True)
def in_design(self):
return self._block_on_hold(stage='SUB')
return not self.on_hold and self._block_on_hold(stage='SUB')
@display(boolean=True)
def in_fab(self):
return self._block_on_hold(stage='FAB')
if self.on_hold:
return False
my_xmtls = Transmittal.objects.filter(stairs__in=[self])
fab_available = any([xmtl.response in ['NC', 'AN'] or xmtl.for_record for xmtl in my_xmtls])
if not fab_available:
return False
return self.has_open_calendar_slots()
@display(boolean=True)
def at_engineering(self):
@ -745,7 +774,7 @@ class Transmittal(models.Model, StairNamesMixin):
elif self.to_engr:
return 'Engineering'
else:
return ''
return 'In Design'
def effective_date(self):
if self.status() == 'Returned':

@ -399,7 +399,7 @@
{% for j in jobs %}
<li class="nav-link p-1"
style="--bs-nav-link-margin-x: 3px">
<a class="btn btn-sm btn-outline-secondary {% if j == job %}active{% endif %}"
<a class="btn btn-sm"
style="--bs-btn-border-color: {{ j.status_color }};"
href="{% url 'jobs:job_detail' pk=j.pk %}">
{{ j.number }}

@ -14,22 +14,22 @@
</div>
<div class="d-flex flex-wrap justify-content-end">
{% with badge_class='badge rounded-pill ms-1 mt-1' %}
{% if job.stairs_in_design %}
{% if job.is_in_design %}
<span class="{{ badge_class }}"
style="background-color: blue"
>Design</span>
{% endif %}
{% if job.stairs_in_fab %}
{% if job.is_in_fab %}
<span class="{{ badge_class }}"
style="background-color: red"
>Fab</span>
{% endif %}
{% if job.stairs_at_engineering %}
{% if job.is_at_engineering %}
<span class="{{ badge_class }}"
style="background-color: green"
>Engineering</span>
{% endif %}
{% if job.stairs_at_submittal %}
{% if job.is_at_submittal %}
<span class="{{ badge_class }}"
style="background-color: orange"
>Submittal</span>

Loading…
Cancel
Save