Merge pull request #207 from SchrodingersGat/build-list

Split build list display
This commit is contained in:
Oliver 2019-05-02 21:32:33 +10:00 committed by GitHub
commit a70ec0b179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 20 deletions

View File

@ -133,6 +133,9 @@ class Build(models.Model):
for item in self.allocated_stock.all():
item.delete()
# Date of 'completion' is the date the build was cancelled
self.completion_date = datetime.now().date()
self.status = self.CANCELLED
self.save()

View File

@ -1,4 +1,20 @@
{% extends "collapse.html" %}
{% block collapse_title %}
<b>{{ title }}</b> - {{ builds | length }}
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed build-table' id='build-table-{{collapse_id}}' data-toolbar='#button-toolbar'>
<thead>
<tr>
<th>Build</th>
<th>Part</th>
<th>Quantity</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for build in builds %}
<tr>
<td><a href="{% url 'build-detail' build.id %}">{{ build.title }}</a></td>
@ -6,4 +22,7 @@
<td>{{ build.quantity }}</td>
<td>{% include "build_status.html" with build=build %}
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -2,28 +2,40 @@
{% load static %}
{% block content %}
<h3>Part Builds</h3>
<div id='button-toolbar'>
<button class="btn btn-success" id='new-build'>Start New Build</button>
<h4>Active Builds</h4>
<div id='active-build-toolbar'>
<div class='btn-group'>
<button class="btn btn-success" id='new-build'>Start New Build</button>
</div>
</div>
<table class='table table-striped table-condensed' id='build-table' data-toolbar='#button-toolbar'>
<thead>
<table class='table table-striped table-condensed build-table' id='build-table-{{collapse_id}}' data-toolbar='#active-build-toolbar'>
<thead>
<tr>
<th>Build</th>
<th>Part</th>
<th>Quantity</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for build in active %}
<tr>
<th>Build</th>
<th>Part</th>
<th>Quantity</th>
<th>Status</th>
<td><a href="{% url 'build-detail' build.id %}">{{ build.title }}</a></td>
<td><a href="{% url 'part-build' build.part.id %}">{{ build.part.name }}</a></td>
<td>{{ build.quantity }}</td>
<td>{% include "build_status.html" with build=build %}
</tr>
</thead>
<tbody>
{% include "build/build_list.html" with builds=builds %}
{% endfor %}
</tbody>
</table>
<p></p>
{% include "build/build_list.html" with builds=completed title="Completed Builds" collapse_id="complete" %}
<p></p>
{% include "build/build_list.html" with builds=cancelled title="Cancelled Builds" collapse_id="cancelled" %}
{% include 'modals.html' %}
@ -39,9 +51,10 @@
});
});
$("#build-table").bootstrapTable({
$(".build-table").bootstrapTable({
sortable: true,
search: true,
formatNoMatches: function() { return 'No builds found'; },
columns: [
{
field: 'name',

View File

@ -33,12 +33,10 @@ class BuildIndex(ListView):
context = super(BuildIndex, self).get_context_data(**kwargs).copy()
"""
context['active'] = self.get_queryset().filter(status__in=[Build.PENDING, Build.HOLDING])
context['active'] = self.get_queryset().filter(status__in=[Build.PENDING, ])
context['complete'] = self.get_queryset().filter(status=Build.COMPLETE)
context['completed'] = self.get_queryset().filter(status=Build.COMPLETE)
context['cancelled'] = self.get_queryset().filter(status=Build.CANCELLED)
"""
return context