From ad0b710363dd0339b8e8a910ea05a0634417b3ed Mon Sep 17 00:00:00 2001 From: Eliseu Egewarth Date: Tue, 20 Jun 2017 18:45:36 -0300 Subject: [PATCH] =?UTF-8?q?Corrige=20updateView=20de=20RelatoriaCrud=20par?= =?UTF-8?q?a=20mostrar=20apenas=20os=20membros=20atuais=20da=20comiss?= =?UTF-8?q?=C3=A3o=20(#1213)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Eliseu Egewarth --- sapl/materia/views.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sapl/materia/views.py b/sapl/materia/views.py index d9a9e1e91..90aab768f 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -883,6 +883,28 @@ class RelatoriaCrud(MasterDetailCrud): class UpdateView(MasterDetailCrud.UpdateView): form_class = RelatoriaForm + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + + try: + comissao = Comissao.objects.get( + pk=context['form'].initial['comissao']) + except ObjectDoesNotExist: + pass + else: + composicao = comissao.composicao_set.last() + participacao = Participacao.objects.filter( + composicao=composicao) + + parlamentares = [] + for p in participacao: + if p.titular: + parlamentares.append( + [p.parlamentar.id, p.parlamentar.nome_parlamentar]) + context['form'].fields['parlamentar'].choices = parlamentares + + return context + class TramitacaoCrud(MasterDetailCrud): model = Tramitacao