Issue#3396 Obter Integrantes da mesa pela API#3415
Conversation
sapl/api/views.py
Outdated
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Remover essas linhas.
sapl/api/views.py
Outdated
|
|
||
| sessao_legislativa = SessaoLegislativa.objects.filter(**kwargs).order_by('-data_inicio').first() | ||
|
|
||
| query_legislatura = Legislatura.objects.filter(id=legislatura).order_by('-data_inicio').first() |
There was a problem hiding this comment.
E se não for informada a legislatura?
There was a problem hiding this comment.
Vc tem certeza de que precisa dessa query????
legislatura = sessao_legislativa.legislatura
vai recuperar o objeto Legislatura
sapl/api/views.py
Outdated
|
|
||
| legislatura = request.GET.get('legislatura') | ||
| if legislatura: | ||
| kwargs['legislatura_id'] = legislatura |
There was a problem hiding this comment.
Acho que é o caso de se colocar a última legislatura se o usuário não informou. Um else aqui, por exemplo, visto que usamos isso na linha 71.
There was a problem hiding this comment.
Verificar a possibilidade do BD estar vazio e sem legislatura.
sapl/api/views.py
Outdated
| if sessao: | ||
| kwargs['id'] = sessao | ||
|
|
||
| sessao_legislativa = SessaoLegislativa.objects.filter(**kwargs).order_by('-data_inicio').first() |
There was a problem hiding this comment.
Temos que pensar o que fazer se sessao_legislativa vier None.
There was a problem hiding this comment.
Colocar um select_related('legislatura') após o objects na linha 69.
sapl/api/views.py
Outdated
| if sessao: | ||
| kwargs['id'] = sessao | ||
|
|
||
| sessao_legislativa = SessaoLegislativa.objects.filter(**kwargs).order_by('-data_inicio').first() |
There was a problem hiding this comment.
Colocar um select_related('legislatura') após o objects na linha 69.
sapl/api/views.py
Outdated
|
|
||
| legislatura = request.GET.get('legislatura') | ||
| if legislatura: | ||
| kwargs['legislatura_id'] = legislatura |
There was a problem hiding this comment.
Coloca um else aqui: se não tiver legislatura informada pega a última ("-data_inicio")
sapl/api/views.py
Outdated
|
|
||
| if sessao_legislativa is None: | ||
| logger.error("Sessão ou legislatura não encontrada!") | ||
| return JsonResponse({}) |
There was a problem hiding this comment.
Retorna uma mensagem de erro no json. Algo como:
{"error": "Sessão ou legislatura não encontrada!"}
sapl/api/views.py
Outdated
|
|
||
| if composicao_mesa is None: | ||
| logger.error("Nenhuma mesa não encontrada!") | ||
| return JsonResponse({}) |
There was a problem hiding this comment.
Mesma coisa aqui: retorna uma mensagem de erro.
sapl/api/views.py
Outdated
| logger.error("Sessão ou legislatura não encontrada!") | ||
| return JsonResponse({}) | ||
|
|
||
| composicao_mesa = ComposicaoMesa.objects.select_related('parlamentar', 'cargo').all().filter( |
There was a problem hiding this comment.
Não precisa colocar o all() e o filter() ao mesmo tempo. É desnecessário. Ou um ou outro. No caso fica o filter().
| 'is_authenticated': request.user.is_authenticated, | ||
| } | ||
| return Response(content) | ||
| return Response(content) No newline at end of file |
There was a problem hiding this comment.
Pq vc tá modificando essa linha? Não precisa. Reverter essa mudança.
7f1daea to
78456b6
Compare
44c7429 to
bda00ac
Compare
f92c461 to
3faba84
Compare
Descrição
Definida nova url e view na API para acessar dados da mesa diretora
Issue Relacionada
#3396
Motivação e Contexto
Como Isso Foi Testado?
Capturas de Tela (se apropriado):
Tipos de Mudanças
Checklist: