2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 21:45:39 +00:00

Changed some category views to use boostrap list-group

- Looks much fancier!
This commit is contained in:
Oliver
2018-04-14 23:05:36 +10:00
parent 0e2c5e6af5
commit 204874dcb4
6 changed files with 220 additions and 24 deletions

View File

@ -20,6 +20,20 @@ class PartCategory(InvenTreeTree):
verbose_name = "Part Category"
verbose_name_plural = "Part Categories"
@property
def partcount(self):
""" Return the total part count under this category
(including children of child categories)
"""
count = self.parts.count()
for child in self.children.all():
count += child.partcount
return count
"""
@property
def parts(self):

View File

@ -1,35 +1,32 @@
{% extends "base.html" %}
{% load static %}
{% block content %}
{% include "part/cat_link.html" with category=category %}
{% if children|length > 0 %}
<table>
<tr>
<th>Subcategory</th>
<th>Description</th>
</tr>
Subcategories:
<ul class="list-group">
{% for child in children %}
<tr>
<td><a href="/part/list/?category={{ child.id }}">{{ child.name }}</a></td>
<td>{{ child.description }}</td>
<li class="list-group-item">
<a href="/part/list/?category={{ child.id }}">{{ child.name }}</a> - {{ child.description }}
<span class='badge'>{{ child.partcount }}</span>
</li>
{% endfor %}
</table>
</ul>
{% endif %}
{% if parts|length > 0 %}
<h3>Parts</h3>
<table>
Parts:
<ul class="list-group">
{% for part in parts %}
<tr>
<td><a href="{% url 'part-detail' part.id %}">{{ part.name }}</a></td>
<td>{{ part.description }}</td>
<li class="list-group-item">
<a href="{% url 'part-detail' part.id %}">{{ part.name }}</a> - {{ part.description }}
</li>
</tr>
{% endfor %}
</table>
{% else %}
There are no parts in this category.
</ul>
{% endif %}
{% endblock %}