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)