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

MOAR FEATURES:

- Add admin view for PartCategoryStar
- Add starred status to partcategory API
- Can filter by "starred" status
- Rename internal functions back to using "starred" (front-end now uses the term "subscribe")
This commit is contained in:
Oliver
2021-11-03 23:22:31 +11:00
parent f9a00b7a90
commit 7567b8dd63
7 changed files with 126 additions and 70 deletions

View File

@ -33,12 +33,27 @@ from .models import (BomItem, BomItemSubstitute,
class CategorySerializer(InvenTreeModelSerializer):
""" Serializer for PartCategory """
def __init__(self, *args, **kwargs):
self.starred_categories = kwargs.pop('starred_categories', [])
super().__init__(*args, **kwargs)
def get_starred(self, category):
"""
Return True if the category is directly "starred" by the current user
"""
return category in self.starred_categories
url = serializers.CharField(source='get_absolute_url', read_only=True)
parts = serializers.IntegerField(source='item_count', read_only=True)
level = serializers.IntegerField(read_only=True)
starred = serializers.SerializerMethodField()
class Meta:
model = PartCategory
fields = [
@ -51,6 +66,7 @@ class CategorySerializer(InvenTreeModelSerializer):
'parent',
'parts',
'pathstring',
'starred',
'url',
]