From dfb0b6a31ce226b551dd156f00cf44203d77bb8d Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Tue, 17 Nov 2020 21:38:47 -0300 Subject: [PATCH] =?UTF-8?q?HOT-FIX:=20endpoint=20list=20expedientes=20de?= =?UTF-8?q?=20uma=20sess=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit em caso de uso do query params get_all=true o serializer utilizado era o da viewset do action, além disso, foi adicionado o filterset correspondente ao endpoint para que query params funcionem no endpoint. --- sapl/api/views.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sapl/api/views.py b/sapl/api/views.py index 097ba3e33..f56087ae3 100644 --- a/sapl/api/views.py +++ b/sapl/api/views.py @@ -620,15 +620,23 @@ class _SessaoPlenariaViewSet: def expedientes(self, request, *args, **kwargs): sessao = self.get_object() + # viewset expediente + api_expediente = SaplApiViewSetConstrutor.get_class_for_model( + ExpedienteSessao + ) - page = self.paginate_queryset(sessao.expedientesessao_set.all()) - if page is not None: - serializer = SaplApiViewSetConstrutor.get_class_for_model( - ExpedienteSessao).serializer_class(page, many=True) - return self.get_paginated_response(serializer.data) + self.serializer_class = api_expediente.serializer_class + self.filterset_class = api_expediente.filterset_class + self.queryset = sessao.expedientesessao_set.all() - serializer = self.get_serializer(page, many=True) - return Response(serializer.data) + qs = self.filter_queryset(self.get_queryset()) + + page = self.paginate_queryset(qs) + data = self.serializer_class( + page if page is not None else qs, many=True).data + + return self.get_paginated_response( + data) if page is not None else Response(data) @customize(NormaJuridica)