mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Added a categorylist page
Displays list of all top-level part categories
This commit is contained in:
parent
3f81046a26
commit
b919418fb5
@ -16,10 +16,10 @@ class PartCategory(models.Model):
|
|||||||
# Return the parent path of this category
|
# Return the parent path of this category
|
||||||
@property
|
@property
|
||||||
def path(self):
|
def path(self):
|
||||||
parent_path = []
|
|
||||||
|
|
||||||
if self.parent:
|
if self.parent:
|
||||||
parent_path = self.parent.path + [self.parent]
|
return self.parent.path + [self.parent]
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
return parent_path
|
return parent_path
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{# Construct the category path #}
|
{# Construct the category path #}
|
||||||
|
<a href="../">Category</a>/
|
||||||
{% for path_item in category.path %}
|
{% for path_item in category.path %}
|
||||||
<a href="../{{ path_item.pk }}">{{ path_item.name }}</a>/
|
<a href="../{{ path_item.pk }}">{{ path_item.name }}</a>/
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
8
InvenTree/part/templates/part/categorylist.html
Normal file
8
InvenTree/part/templates/part/categorylist.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Top Level Part Categories:
|
||||||
|
|
||||||
|
{% for category in categories %}
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<a href="./{{ category.pk }}">{{ category.name }}<a/>
|
||||||
|
|
||||||
|
{% endfor %}
|
@ -6,7 +6,10 @@ urlpatterns = [
|
|||||||
# Display part detail
|
# Display part detail
|
||||||
url(r'^(?P<part_id>[0-9]+)/$', views.partdetail, name='detail'),
|
url(r'^(?P<part_id>[0-9]+)/$', views.partdetail, name='detail'),
|
||||||
|
|
||||||
# Display a part category
|
# Display a list of top-level categories
|
||||||
|
url(r'^category/$', views.categorylist, name='categorylist'),
|
||||||
|
|
||||||
|
# Display a single part category
|
||||||
url(r'^category/(?P<category_id>[0-9]+)/$', views.category, name='category'),
|
url(r'^category/(?P<category_id>[0-9]+)/$', views.category, name='category'),
|
||||||
url(r'^$', views.index, name='index')
|
url(r'^$', views.index, name='index')
|
||||||
]
|
]
|
@ -13,6 +13,13 @@ def partdetail(request, part_id):
|
|||||||
return render(request, 'part/detail.html',
|
return render(request, 'part/detail.html',
|
||||||
{'part': part})
|
{'part': part})
|
||||||
|
|
||||||
|
def categorylist(request):
|
||||||
|
categories = PartCategory.objects.filter(parent = None)
|
||||||
|
|
||||||
|
return render(request, 'part/categorylist.html',
|
||||||
|
{'categories': categories
|
||||||
|
})
|
||||||
|
|
||||||
def category(request, category_id):
|
def category(request, category_id):
|
||||||
|
|
||||||
# Find the category
|
# Find the category
|
||||||
|
Loading…
Reference in New Issue
Block a user