From 1148f993e2e812b1b9cacabfa084d858120b84b6 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Wed, 21 Aug 2019 09:32:10 -0300 Subject: [PATCH] add na api endpoint para normas de destaque --- sapl/api/views.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sapl/api/views.py b/sapl/api/views.py index 48f06a3c5..6f4e9219a 100644 --- a/sapl/api/views.py +++ b/sapl/api/views.py @@ -24,6 +24,7 @@ from sapl.api.serializers import ChoiceSerializer from sapl.base.models import Autor, AppConfig, DOC_ADM_OSTENSIVO from sapl.materia.models import Proposicao, TipoMateriaLegislativa,\ MateriaLegislativa, Tramitacao +from sapl.norma.models import NormaJuridica from sapl.parlamentares.models import Parlamentar from sapl.protocoloadm.models import DocumentoAdministrativo,\ DocumentoAcessorioAdministrativo, TramitacaoAdministrativo, Anexado @@ -201,6 +202,8 @@ SaplApiViewSetConstrutor.build_class() # rest_framework.viewsets.ModelViewSet conforme exemplo para a classe autor # decorator para recuperar e transformar o default + + class customize(object): def __init__(self, model): self.model = model @@ -522,3 +525,12 @@ class _SessaoPlenariaViewSet: serializer = self.get_serializer(page, many=True) return Response(serializer.data) + + +@customize(NormaJuridica) +class _NormaJuridicaViewset: + + @action(detail=False, methods=['GET']) + def destaques(self, request, *args, **kwargs): + self.queryset = self.get_queryset().filter(norma_de_destaque=True) + return self.list(request, *args, **kwargs)