mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Logic fix for part filtering
This commit is contained in:
parent
e86bc4fa6d
commit
e1c6ad7761
@ -149,6 +149,13 @@ class PartList(generics.ListCreateAPIView):
|
||||
|
||||
- GET: Return list of objects
|
||||
- POST: Create a new Part object
|
||||
|
||||
The Part object list can be filtered by:
|
||||
- category: Filter by PartCategory reference
|
||||
- cascade: If true, include parts from sub-categories
|
||||
- is_template: Is the part a template part?
|
||||
- variant_of: Filter by variant_of Part reference
|
||||
- assembly: Filter by assembly field
|
||||
"""
|
||||
|
||||
serializer_class = part_serializers.PartSerializer
|
||||
@ -291,13 +298,13 @@ class PartList(generics.ListCreateAPIView):
|
||||
|
||||
cascade = str2bool(self.request.query_params.get('cascade', False))
|
||||
|
||||
if cat_id is not None:
|
||||
|
||||
if isNull(cat_id):
|
||||
if cat_id is None:
|
||||
# Top-level parts
|
||||
if not cascade:
|
||||
parts_list = parts_list.filter(category=None)
|
||||
|
||||
else:
|
||||
try:
|
||||
cat_id = int(cat_id)
|
||||
category = PartCategory.objects.get(pk=cat_id)
|
||||
|
||||
# If '?cascade=true' then include parts which exist in sub-categories
|
||||
|
Loading…
Reference in New Issue
Block a user