Browse Source

add endpoint get ultima_tramitacao

pull/2683/head
Leandro Roberto 6 years ago
parent
commit
5dd0cdcd89
  1. 19
      sapl/api/views.py

19
sapl/api/views.py

@ -348,6 +348,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'])
@ -442,6 +459,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