From 5d70f496a5ad6d4d3043e676fa4e47dc644c54a2 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 11 Apr 2020 20:03:31 +1000 Subject: [PATCH] Ability to filter build list by status --- InvenTree/build/api.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/InvenTree/build/api.py b/InvenTree/build/api.py index 3be81f7b59..1476af3dcd 100644 --- a/InvenTree/build/api.py +++ b/InvenTree/build/api.py @@ -41,6 +41,22 @@ class BuildList(generics.ListCreateAPIView): 'part', ] + def get_queryset(self): + """ + Override the queryset filtering, + as some of the fields don't natively play nicely with DRF + """ + + build_list = super().get_queryset() + + # Filter by build status? + status = self.request.query_params.get('status', None) + + if status is not None: + build_list = build_list.filter(status=status) + + return build_list + def get_serializer(self, *args, **kwargs): try: