Browse Source

add endpoint get ultima_tramitacao

pull/2677/head
Leandro Roberto 6 years ago
parent
commit
8068e64be4
  1. 19
      sapl/api/views.py

19
sapl/api/views.py

@ -349,6 +349,23 @@ class _ProposicaoViewSet(SaplSetViews['materia']['proposicao']):
return qs
class _MateriaLegislativaViewSet(SaplSetViews['materia']['materialegislativa']):
@action(detail=True, methods=['GET'])
def ultima_tramitacao(self, request, *args, **kwargs):
materia = self.get_object()
if not materia.tramitacao_set.exists():
return Response({})
ultima_tramitacao = materia.tramitacao_set.last()
serializer_class = SaplSetViews[
'materia']['tramitacao'].serializer_class(ultima_tramitacao)
return Response(serializer_class.data)
class _TipoMateriaLegislativaViewSet(SaplSetViews['materia']['tipomaterialegislativa']):
@action(detail=True, methods=['POST'])
@ -443,6 +460,8 @@ class _SessaoPlenariaViewSet(
SaplSetViews['base']['autor'] = _AutorViewSet.build_class_with_actions()
SaplSetViews['materia']['materialegislativa'] = _MateriaLegislativaViewSet
SaplSetViews['materia']['proposicao'] = _ProposicaoViewSet
SaplSetViews['materia']['tipomaterialegislativa'] = _TipoMateriaLegislativaViewSet

Loading…
Cancel
Save