2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-07 04:12:11 +00:00

Added helper functions, improved UI

This commit is contained in:
Oliver
2018-04-16 23:26:02 +10:00
parent a67d5b58db
commit 937470750b
12 changed files with 50 additions and 29 deletions

View File

@@ -35,11 +35,9 @@ class PartCategory(InvenTreeTree):
return count
"""
@property
def parts(self):
return self.part_set.all()
"""
def has_parts(self):
return self.parts.count() > 0
@receiver(pre_delete, sender=PartCategory, dispatch_uid='partcategory_delete_log')
@@ -186,16 +184,16 @@ class Part(models.Model):
@property
def bom_count(self):
return self.bom_items.all().count()
return self.bom_items.count()
@property
def used_in_count(self):
return self.used_in.all().count()
return self.used_in.count()
@property
def supplier_count(self):
# Return the number of supplier parts available for this part
return self.supplier_parts.all().count()
return self.supplier_parts.count()
"""
@property

View File

@@ -11,9 +11,15 @@
<i>{{ category.description }}</i>
</p>
{% if category.has_children %}
<h4>Subcategories</h4>
{% include "part/category_subcategories.html" with children=category.children.all %}
{% endif %}
{% if category.has_parts %}
<h4>Parts</h4>
{% include "part/category_parts.html" with parts=category.parts.all %}
{% endif %}
<div class='container-fluid'>
<a href="{% url 'category-create' %}?category={{ category.id }}">

View File

@@ -1,5 +1,3 @@
{% if parts|length > 0 %}
Parts:
<table class="table table-striped">
<tr>
<th>Part</th>
@@ -11,5 +9,4 @@ Parts:
<td>{{ part.description }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
</table>

View File

@@ -1,5 +1,3 @@
{% if children|length > 0 %}
Subcategories:
<ul class="list-group">
{% for child in children %}
<li class="list-group-item">
@@ -10,5 +8,4 @@ Subcategories:
<span class='badge'>{{ child.partcount }}</span>
</li>
{% endfor %}
</ul>
{% endif %}
</ul>

View File

@@ -5,9 +5,15 @@
{% include "part/cat_link.html" with category=category %}
{% if children.all|length > 0 %}
<h4>Part Categories</h4>
{% include "part/category_subcategories.html" with children=children %}
{% endif %}
{% if parts.all|length > 0%}
<h4>Top Level Parts</h4>
{% include "part/category_parts.html" with parts=parts %}
{% endif %}
<div class='container-fluid'>
<a href="{% url 'category-create' %}">