Add "child build" page

This commit is contained in:
Oliver Walters 2021-02-22 22:21:46 +11:00
parent 2186a66465
commit c1dd5b1ca1
5 changed files with 41 additions and 0 deletions

View File

@ -259,6 +259,23 @@ class Build(MPTTModel):
blank=True, help_text=_('Extra build notes')
)
def sub_builds(self, cascade=True):
"""
Return all Build Order objects under this one.
"""
if cascade:
return Build.objects.filter(parent=self.pk)
else:
descendants = self.get_descendants(include_self=True)
Build.objects.filter(parent__pk__in=[d.pk for d in descendants])
def sub_build_count(self, cascade=True):
return self.sub_builds(cascade=cascade).count()
@property
def is_overdue(self):
"""

View File

@ -0,0 +1,16 @@
{% extends "build/build_base.html" %}
{% load static %}
{% load i18n %}
{% block details %}
{% include "build/tabs.html" with tab="children" %}
<h4>{% trans "Child Build Orders" %}</h4>
<hr>
{% endblock %}
{% block js_ready %}
{% endblock %}

View File

@ -24,6 +24,12 @@
<span class='badge'>{{ build.output_count }}</span>
</a>
</li>
<li {% if tab == 'children' %} class='active'{% endif %}>
<a href='{% url "build-children" build.id %}'>
{% trans "Child Builds" %}
<span class='badge'>{{ build.sub_build_count }}</span>
</a>
</li>
<li{% if tab == 'notes' %} class='active'{% endif %}>
<a href="{% url 'build-notes' build.id %}">
{% trans "Notes" %}

View File

@ -20,6 +20,7 @@ build_detail_urls = [
url(r'^notes/', views.BuildNotes.as_view(), name='build-notes'),
url(r'^children/', views.BuildDetail.as_view(template_name='build/build_children.html'), name='build-children'),
url(r'^parts/', views.BuildDetail.as_view(template_name='build/parts.html'), name='build-parts'),
url(r'^attachments/', views.BuildDetail.as_view(template_name='build/attachments.html'), name='build-attachments'),
url(r'^output/', views.BuildDetail.as_view(template_name='build/build_output.html'), name='build-output'),

View File

@ -618,6 +618,7 @@ class BuildDetail(DetailView):
ctx['bom_price'] = build.part.get_price_info(build.quantity, buy=False)
ctx['BuildStatus'] = BuildStatus
ctx['sub_build_count'] = build.sub_build_count()
return ctx