mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 03:56:43 +00:00
Filtering improvements
This commit is contained in:
parent
883efd0945
commit
057fd1dd20
@ -31,8 +31,6 @@ class PartDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
class PartParamFilter(FilterSet):
|
class PartParamFilter(FilterSet):
|
||||||
|
|
||||||
part = NumberFilter(name='part', lookup_expr='exact')
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PartParameter
|
model = PartParameter
|
||||||
fields = ['part']
|
fields = ['part']
|
||||||
@ -75,7 +73,6 @@ class PartParamDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class PartFilter(FilterSet):
|
class PartFilter(FilterSet):
|
||||||
category = NumberFilter(name='category', lookup_expr='exact')
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Part
|
model = Part
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from rest_framework import generics, permissions
|
from django_filters.rest_framework import FilterSet, DjangoFilterBackend
|
||||||
|
|
||||||
|
from rest_framework import generics, permissions
|
||||||
from InvenTree.models import FilterChildren
|
from InvenTree.models import FilterChildren
|
||||||
from .models import ProjectCategory, Project, ProjectPart
|
from .models import ProjectCategory, Project, ProjectPart
|
||||||
from .serializers import ProjectSerializer
|
from .serializers import ProjectSerializer
|
||||||
@ -26,6 +27,13 @@ class ProjectDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
||||||
|
|
||||||
|
|
||||||
|
class ProjectFilter(FilterSet):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Project
|
||||||
|
fields = ['category']
|
||||||
|
|
||||||
|
|
||||||
class ProjectList(generics.ListCreateAPIView):
|
class ProjectList(generics.ListCreateAPIView):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -38,19 +46,11 @@ class ProjectList(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_queryset(self):
|
queryset = Project.objects.all()
|
||||||
projects = Project.objects.all()
|
|
||||||
params = self.request.query_params
|
|
||||||
|
|
||||||
cat_id = params.get('category', None)
|
|
||||||
|
|
||||||
if cat_id:
|
|
||||||
projects = projects.filter(category=cat_id)
|
|
||||||
|
|
||||||
return projects
|
|
||||||
|
|
||||||
serializer_class = ProjectSerializer
|
serializer_class = ProjectSerializer
|
||||||
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
||||||
|
filter_backends = (DjangoFilterBackend,)
|
||||||
|
filter_class = ProjectFilter
|
||||||
|
|
||||||
|
|
||||||
class ProjectCategoryDetail(generics.RetrieveUpdateAPIView):
|
class ProjectCategoryDetail(generics.RetrieveUpdateAPIView):
|
||||||
@ -136,7 +136,7 @@ class ProjectPartDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
delete:
|
delete:
|
||||||
Remove a ProjectPart
|
Remove a ProjectPart
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
queryset = ProjectPart.objects.all()
|
queryset = ProjectPart.objects.all()
|
||||||
|
@ -11,6 +11,7 @@ class StockItemSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
model = StockItem
|
model = StockItem
|
||||||
fields = ('url',
|
fields = ('url',
|
||||||
'part',
|
'part',
|
||||||
|
'supplier_part',
|
||||||
'location',
|
'location',
|
||||||
'quantity',
|
'quantity',
|
||||||
'status',
|
'status',
|
||||||
|
@ -29,8 +29,6 @@ class StockDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
class StockFilter(FilterSet):
|
class StockFilter(FilterSet):
|
||||||
min_stock = NumberFilter(name='quantity', lookup_expr='gte')
|
min_stock = NumberFilter(name='quantity', lookup_expr='gte')
|
||||||
max_stock = NumberFilter(name='quantity', lookup_expr='lte')
|
max_stock = NumberFilter(name='quantity', lookup_expr='lte')
|
||||||
part = NumberFilter(name='part', lookup_expr='exact')
|
|
||||||
location = NumberFilter(name='location', lookup_expr='exact')
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = StockItem
|
model = StockItem
|
||||||
@ -76,8 +74,6 @@ class LocationDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
class StockLocationFilter(FilterSet):
|
class StockLocationFilter(FilterSet):
|
||||||
|
|
||||||
parent = NumberFilter(name='parent', lookup_expr='exact')
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = StockLocation
|
model = StockLocation
|
||||||
fields = ['parent']
|
fields = ['parent']
|
||||||
@ -123,8 +119,6 @@ class StockTrackingDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
class StockTrackingFilter(FilterSet):
|
class StockTrackingFilter(FilterSet):
|
||||||
|
|
||||||
item = NumberFilter(name='item', lookup_expr='exact')
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = StockTracking
|
model = StockTracking
|
||||||
fields = ['item']
|
fields = ['item']
|
||||||
|
@ -138,12 +138,6 @@ class SupplierPartDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
class SupplierPartFilter(FilterSet):
|
class SupplierPartFilter(FilterSet):
|
||||||
|
|
||||||
supplier = NumberFilter(name='supplier', lookup_expr='exact')
|
|
||||||
|
|
||||||
part = NumberFilter(name='part', lookup_expr='exact')
|
|
||||||
|
|
||||||
manufacturer = NumberFilter(name='manufacturer', lookup_expr='exact')
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SupplierPart
|
model = SupplierPart
|
||||||
fields = ['supplier', 'part', 'manufacturer']
|
fields = ['supplier', 'part', 'manufacturer']
|
||||||
@ -190,8 +184,6 @@ class SupplierPriceBreakDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
class PriceBreakFilter(FilterSet):
|
class PriceBreakFilter(FilterSet):
|
||||||
|
|
||||||
part = NumberFilter(name='part', lookup_expr='exact')
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SupplierPriceBreak
|
model = SupplierPriceBreak
|
||||||
fields = ['part']
|
fields = ['part']
|
||||||
|
@ -5,8 +5,6 @@ from .models import UniquePart, PartTrackingInfo
|
|||||||
|
|
||||||
class UniquePartSerializer(serializers.HyperlinkedModelSerializer):
|
class UniquePartSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
||||||
tracking_info = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = UniquePart
|
model = UniquePart
|
||||||
fields = ['url',
|
fields = ['url',
|
||||||
@ -15,8 +13,7 @@ class UniquePartSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
'serial',
|
'serial',
|
||||||
# 'createdBy',
|
# 'createdBy',
|
||||||
'customer',
|
'customer',
|
||||||
'status',
|
'status']
|
||||||
'tracking_info']
|
|
||||||
|
|
||||||
|
|
||||||
class PartTrackingInfoSerializer(serializers.HyperlinkedModelSerializer):
|
class PartTrackingInfoSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
@ -31,10 +31,6 @@ class UniquePartFilter(FilterSet):
|
|||||||
min_sn = NumberFilter(name='serial', lookup_expr='gte')
|
min_sn = NumberFilter(name='serial', lookup_expr='gte')
|
||||||
max_sn = NumberFilter(name='serial', lookup_expr='lte')
|
max_sn = NumberFilter(name='serial', lookup_expr='lte')
|
||||||
|
|
||||||
sn = NumberFilter(name='serial', lookup_expr='exact')
|
|
||||||
part = NumberFilter(name='part', lookup_expr='exact')
|
|
||||||
customer = NumberFilter(name='customer', lookup_expr='exact')
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = UniquePart
|
model = UniquePart
|
||||||
fields = ['serial', 'part', 'customer']
|
fields = ['serial', 'part', 'customer']
|
||||||
@ -77,7 +73,6 @@ class PartTrackingDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class PartTrackingFilter(FilterSet):
|
class PartTrackingFilter(FilterSet):
|
||||||
part = NumberFilter(name='part', lookup_expr='exact')
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PartTrackingInfo
|
model = PartTrackingInfo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user