From 76c79403f223056770af4e36d279c9076da67bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 4 Jan 2022 19:59:05 +0100 Subject: [PATCH 1/5] Add filtering to component API --- shimatta_kenkyusho/api/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shimatta_kenkyusho/api/views.py b/shimatta_kenkyusho/api/views.py index fce8f85..3ec6412 100644 --- a/shimatta_kenkyusho/api/views.py +++ b/shimatta_kenkyusho/api/views.py @@ -57,8 +57,9 @@ class PartsComponentTypeViewSet(viewsets.ModelViewSet): queryset = parts_models.ComponentType.objects.all() serializer_class = ComponentTypeSerializer permission_classes = [permissions.DjangoModelPermissions] - filter_backends = [filters.SearchFilter] + filter_backends = [filters.SearchFilter, django_filters.rest_framework.DjangoFilterBackend] search_fields = ['class_name'] + filterset_fields = ['id', 'name'] class PartsComponentParameterTypeViewSet(viewsets.ModelViewSet): queryset = parts_models.ComponentParameterType.objects.all() From 3b1eb6118f0b18be5ce34e2e613f6158f431e8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 4 Jan 2022 20:02:13 +0100 Subject: [PATCH 2/5] Revert "Add filtering to component API" This reverts commit 76c79403f223056770af4e36d279c9076da67bc8. --- shimatta_kenkyusho/api/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shimatta_kenkyusho/api/views.py b/shimatta_kenkyusho/api/views.py index 3ec6412..fce8f85 100644 --- a/shimatta_kenkyusho/api/views.py +++ b/shimatta_kenkyusho/api/views.py @@ -57,9 +57,8 @@ class PartsComponentTypeViewSet(viewsets.ModelViewSet): queryset = parts_models.ComponentType.objects.all() serializer_class = ComponentTypeSerializer permission_classes = [permissions.DjangoModelPermissions] - filter_backends = [filters.SearchFilter, django_filters.rest_framework.DjangoFilterBackend] + filter_backends = [filters.SearchFilter] search_fields = ['class_name'] - filterset_fields = ['id', 'name'] class PartsComponentParameterTypeViewSet(viewsets.ModelViewSet): queryset = parts_models.ComponentParameterType.objects.all() From c6fae17154ce2f55e709f5998ce4048b332f4399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 4 Jan 2022 20:03:20 +0100 Subject: [PATCH 3/5] Add filtering to component API --- shimatta_kenkyusho/api/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shimatta_kenkyusho/api/views.py b/shimatta_kenkyusho/api/views.py index fce8f85..9c14f32 100644 --- a/shimatta_kenkyusho/api/views.py +++ b/shimatta_kenkyusho/api/views.py @@ -52,13 +52,15 @@ class PartsComponentViewSet(viewsets.ModelViewSet): permission_classes = [permissions.DjangoModelPermissions] filter_backends = [filters.SearchFilter] search_fields = ['id', 'name', 'package__name', 'manufacturer__name'] + class PartsComponentTypeViewSet(viewsets.ModelViewSet): queryset = parts_models.ComponentType.objects.all() serializer_class = ComponentTypeSerializer permission_classes = [permissions.DjangoModelPermissions] - filter_backends = [filters.SearchFilter] + filter_backends = [filters.SearchFilter, django_filters.rest_framework.DjangoFilterBackend] search_fields = ['class_name'] + filterset_fields = ['id', 'name'] class PartsComponentParameterTypeViewSet(viewsets.ModelViewSet): queryset = parts_models.ComponentParameterType.objects.all() From 1e302e4595409719ff4b7c781b1f00cbadda498c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 4 Jan 2022 20:05:11 +0100 Subject: [PATCH 4/5] Revert "Add filtering to component API" This reverts commit c6fae17154ce2f55e709f5998ce4048b332f4399. --- shimatta_kenkyusho/api/views.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/shimatta_kenkyusho/api/views.py b/shimatta_kenkyusho/api/views.py index 9c14f32..fce8f85 100644 --- a/shimatta_kenkyusho/api/views.py +++ b/shimatta_kenkyusho/api/views.py @@ -52,15 +52,13 @@ class PartsComponentViewSet(viewsets.ModelViewSet): permission_classes = [permissions.DjangoModelPermissions] filter_backends = [filters.SearchFilter] search_fields = ['id', 'name', 'package__name', 'manufacturer__name'] - class PartsComponentTypeViewSet(viewsets.ModelViewSet): queryset = parts_models.ComponentType.objects.all() serializer_class = ComponentTypeSerializer permission_classes = [permissions.DjangoModelPermissions] - filter_backends = [filters.SearchFilter, django_filters.rest_framework.DjangoFilterBackend] + filter_backends = [filters.SearchFilter] search_fields = ['class_name'] - filterset_fields = ['id', 'name'] class PartsComponentParameterTypeViewSet(viewsets.ModelViewSet): queryset = parts_models.ComponentParameterType.objects.all() From 873e13542a529fad4d5650919eccdb25200d746e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 4 Jan 2022 20:06:22 +0100 Subject: [PATCH 5/5] Correctly implement filtering for components --- shimatta_kenkyusho/api/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shimatta_kenkyusho/api/views.py b/shimatta_kenkyusho/api/views.py index fce8f85..8ca59aa 100644 --- a/shimatta_kenkyusho/api/views.py +++ b/shimatta_kenkyusho/api/views.py @@ -50,8 +50,9 @@ class PartsComponentViewSet(viewsets.ModelViewSet): queryset = parts_models.Component.objects.all() serializer_class = ComponentSerializer permission_classes = [permissions.DjangoModelPermissions] - filter_backends = [filters.SearchFilter] + filter_backends = [filters.SearchFilter, django_filters.rest_framework.DjangoFilterBackend] search_fields = ['id', 'name', 'package__name', 'manufacturer__name'] + filterset_fields = ['id', 'name'] class PartsComponentTypeViewSet(viewsets.ModelViewSet): queryset = parts_models.ComponentType.objects.all()