mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Added latest parts and invalid BOMs on homepage
This commit is contained in:
parent
303db293b7
commit
a9fffe6a73
@ -405,6 +405,27 @@ class PartList(generics.ListCreateAPIView):
|
||||
except (ValueError, Part.DoesNotExist):
|
||||
pass
|
||||
|
||||
# Filter by latest part creation date
|
||||
latest_parts = params.get('latest_parts', None)
|
||||
|
||||
if latest_parts is not None:
|
||||
# Get the last 5 created parts
|
||||
queryset = queryset.order_by('-creation_date')[:5]
|
||||
|
||||
# Filter invalid BOMs
|
||||
bom_invalid = params.get('bom_invalid', None)
|
||||
|
||||
if bom_invalid is not None:
|
||||
# Get assemblies with invalid BOMs
|
||||
assemblies = queryset.filter(active=True).filter(assembly=True)
|
||||
valid_boms = []
|
||||
|
||||
for part in assemblies:
|
||||
if part.is_bom_valid:
|
||||
valid_boms.append(part.pk)
|
||||
|
||||
queryset = assemblies.exclude(pk__in=valid_boms)
|
||||
|
||||
# Filter by 'starred' parts?
|
||||
starred = params.get('starred', None)
|
||||
|
||||
|
15
InvenTree/templates/InvenTree/bom_invalid.html
Normal file
15
InvenTree/templates/InvenTree/bom_invalid.html
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends "collapse_index.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block collapse_title %}
|
||||
<span class='fas fa-times-circle icon-header'></span>
|
||||
{% trans "BOM - Missing Validation" %}<span class='badge' id='bom-invalid-count'>0</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block collapse_content %}
|
||||
|
||||
<table class='table table-striped table-condensed' id='bom-invalid-table'>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
@ -7,9 +7,24 @@ InvenTree | Index
|
||||
{% block content %}
|
||||
<h3>InvenTree</h3>
|
||||
<hr>
|
||||
{% include "InvenTree/starred_parts.html" with collapse_id="starred" %}
|
||||
|
||||
{% include "InvenTree/low_stock.html" with collapse_id="order" %}
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
{% include "InvenTree/latest_parts.html" with collapse_id="latest" %}
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
{% include "InvenTree/bom_invalid.html" with collapse_id="bom_invalid" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
{% include "InvenTree/starred_parts.html" with collapse_id="starred" %}
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
{% include "InvenTree/low_stock.html" with collapse_id="order" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@ -21,6 +36,18 @@ InvenTree | Index
|
||||
|
||||
{{ block.super }}
|
||||
|
||||
loadPartTable("#latest-parts-table", "{% url 'api-part-list' %}", {
|
||||
params: {
|
||||
"latest_parts": true,
|
||||
}
|
||||
});
|
||||
|
||||
loadPartTable("#bom-invalid-table", "{% url 'api-part-list' %}", {
|
||||
params: {
|
||||
"bom_invalid": true,
|
||||
}
|
||||
});
|
||||
|
||||
loadPartTable("#starred-parts-table", "{% url 'api-part-list' %}", {
|
||||
params: {
|
||||
"starred": true,
|
||||
@ -33,6 +60,19 @@ loadPartTable("#low-stock-table", "{% url 'api-part-list' %}", {
|
||||
}
|
||||
});
|
||||
|
||||
$("#bom-invalid-table").on('load-success.bs.table', function() {
|
||||
var count = $("#bom-invalid-table").bootstrapTable('getData').length;
|
||||
|
||||
$("#bom-invalid-count").html(count);
|
||||
});
|
||||
|
||||
|
||||
$("#latest-parts-table").on('load-success.bs.table', function() {
|
||||
var count = $("#latest-parts-table").bootstrapTable('getData').length;
|
||||
|
||||
$("#latest-parts-count").html(count);
|
||||
});
|
||||
|
||||
$("#starred-parts-table").on('load-success.bs.table', function() {
|
||||
var count = $("#starred-parts-table").bootstrapTable('getData').length;
|
||||
|
||||
|
15
InvenTree/templates/InvenTree/latest_parts.html
Normal file
15
InvenTree/templates/InvenTree/latest_parts.html
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends "collapse_index.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block collapse_title %}
|
||||
<span class='fas fa-newspaper icon-header'></span>
|
||||
{% trans "Latest Parts" %}<span class='badge' id='latest-parts-count'>0</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block collapse_content %}
|
||||
|
||||
<table class='table table-striped table-condensed' id='latest-parts-table'>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
@ -9,7 +9,7 @@
|
||||
|
||||
{% block collapse_content %}
|
||||
|
||||
<table class='table tabe-striped table-condensed' id='starred-parts-table'>
|
||||
<table class='table table-striped table-condensed' id='starred-parts-table'>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
19
InvenTree/templates/collapse_index.html
Normal file
19
InvenTree/templates/collapse_index.html
Normal file
@ -0,0 +1,19 @@
|
||||
{% block collapse_preamble %}
|
||||
{% endblock %}
|
||||
<div class='panel-group'>
|
||||
<div class='panel panel-default'>
|
||||
<div {% block collapse_panel_setup %}class='panel panel-heading'{% endblock %}>
|
||||
<div class='panel-title'>
|
||||
<a data-toggle='collapse' href="#collapse-item-{{ collapse_id }}">{% block collapse_title %}Title{% endblock %}</a>
|
||||
</div>
|
||||
{% block collapse_heading %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
<div class='panel-collapse collapse' id='collapse-item-{{ collapse_id }}'>
|
||||
<div class='panel-body'>
|
||||
{% block collapse_content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user