mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Don't render full category information in part API
- Lots of data duplication! - Just send the category ID (and the category name) -
This commit is contained in:
parent
ac0b28a06c
commit
3d9a1acc2e
@ -43,7 +43,7 @@ class PartSerializer(serializers.ModelSerializer):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||||
category = CategorySerializer(many=False, read_only=True)
|
category_name = serializers.CharField(source='category_path', read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Part
|
model = Part
|
||||||
@ -55,6 +55,7 @@ class PartSerializer(serializers.ModelSerializer):
|
|||||||
'URL', # Link to an external URL (optional)
|
'URL', # Link to an external URL (optional)
|
||||||
'description',
|
'description',
|
||||||
'category',
|
'category',
|
||||||
|
'category_name',
|
||||||
'total_stock',
|
'total_stock',
|
||||||
'available_stock',
|
'available_stock',
|
||||||
'units',
|
'units',
|
||||||
|
@ -151,11 +151,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
sortable: true,
|
sortable: true,
|
||||||
field: 'category',
|
field: 'category_name',
|
||||||
title: 'Category',
|
title: 'Category',
|
||||||
formatter: function(value, row, index, field) {
|
formatter: function(value, row, index, field) {
|
||||||
if (row.category) {
|
if (row.category) {
|
||||||
return renderLink(row.category.pathstring, row.category.url);
|
return renderLink(row.category_name, "/part/category/" + row.category + "/");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return '';
|
return '';
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
<a data-toggle="collapse" href="#collapse1">Child Categories</a><span class='badge'>{{ children|length }}</span>
|
<a data-toggle="collapse" href="#collapse1">{{ children | length }} Child Categories</a>
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="collapse1" class="panel-collapse collapse">
|
<div id="collapse1" class="panel-collapse collapse">
|
||||||
|
Loading…
Reference in New Issue
Block a user