Browse Source

add na api endpoint para normas de destaque

pull/2944/head
Leandro Roberto 5 years ago
parent
commit
1148f993e2
  1. 12
      sapl/api/views.py

12
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)

Loading…
Cancel
Save