-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue#3396 Obter Integrantes da mesa pela API #3415
base: 3.1.x
Are you sure you want to change the base?
Conversation
sapl/api/views.py
Outdated
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E se não for informada a legislatura?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temos que pensar o que fazer se sessao_legislativa vier None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Não precisa colocar o all() e o filter() ao mesmo tempo. É desnecessário. Ou um ou outro. No caso fica o filter().
@@ -703,4 +747,4 @@ def get(self, request): | |||
'user': request.user.username, | |||
'is_authenticated': request.user.is_authenticated, | |||
} | |||
return Response(content) | |||
return Response(content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pq vc tá modificando essa linha? Não precisa. Reverter essa mudança.
7f1daea
to
78456b6
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: