2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-15 09:21:26 +00:00

add stuff to mark starting endpoint

This commit is contained in:
Matthias
2021-12-07 23:54:45 +01:00
parent 2cf4e20d9a
commit 948270bbcb
3 changed files with 33 additions and 4 deletions

View File

@ -83,6 +83,8 @@ class CategoryTree(InvenTreeModelSerializer):
a_attr = serializers.SerializerMethodField()
state = serializers.SerializerMethodField()
def get_parent(self, obj):
return obj.parent.pk if obj.parent else '#'
@ -92,6 +94,11 @@ class CategoryTree(InvenTreeModelSerializer):
def get_a_attr(self, obj):
return {'href': obj.get_absolute_url()}
def get_state(self, obj):
if 'ancestors' in self.context:
return {'opened': obj in self.context['ancestors'] }
return {}
class Meta:
model = PartCategory
fields = [
@ -100,6 +107,7 @@ class CategoryTree(InvenTreeModelSerializer):
'parent',
'children',
'a_attr',
'state',
]