mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Added part category path string to serializer
This commit is contained in:
parent
25fcd3e9f1
commit
f46c09e3a7
@ -153,6 +153,12 @@ class Part(models.Model):
|
|||||||
verbose_name = "Part"
|
verbose_name = "Part"
|
||||||
verbose_name_plural = "Parts"
|
verbose_name_plural = "Parts"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def category_path(self):
|
||||||
|
if self.category:
|
||||||
|
return self.category.pathstring
|
||||||
|
return ''
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available_stock(self):
|
def available_stock(self):
|
||||||
"""
|
"""
|
||||||
|
@ -17,6 +17,7 @@ class PartSerializer(serializers.ModelSerializer):
|
|||||||
'URL', # Link to an external URL (optional)
|
'URL', # Link to an external URL (optional)
|
||||||
'description',
|
'description',
|
||||||
'category',
|
'category',
|
||||||
|
'category_path',
|
||||||
'total_stock',
|
'total_stock',
|
||||||
'available_stock',
|
'available_stock',
|
||||||
'units',
|
'units',
|
||||||
|
@ -33,7 +33,9 @@ function add_part(part) {
|
|||||||
|
|
||||||
// TODO - Work out how to add in category name + link...
|
// TODO - Work out how to add in category name + link...
|
||||||
if (part.category){
|
if (part.category){
|
||||||
text += "category: " + part.category;
|
text += '<a href="/part/category/' + part.category + '/">';
|
||||||
|
text += part.category_path;
|
||||||
|
text += '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
text += "</td>";
|
text += "</td>";
|
||||||
|
@ -10,10 +10,8 @@
|
|||||||
{% include "part/category_subcategories.html" with children=children %}
|
{% include "part/category_subcategories.html" with children=children %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if parts.all|length > 0%}
|
<h4>Parts</h4>
|
||||||
<h4>Top Level Parts</h4>
|
|
||||||
{% include "part/category_parts.html" with parts=parts %}
|
{% include "part/category_parts.html" with parts=parts %}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class='container-fluid'>
|
<div class='container-fluid'>
|
||||||
<a href="{% url 'category-create' %}">
|
<a href="{% url 'category-create' %}">
|
||||||
|
Loading…
Reference in New Issue
Block a user