From 0c8b39d942437b4f8682fdfee8c85363cf98dd11 Mon Sep 17 00:00:00 2001 From: Cesar Carvalho Date: Tue, 13 Aug 2019 11:37:04 -0300 Subject: [PATCH] =?UTF-8?q?HOT-FIX:=20Retira=20duplicidade=20de=20OradorEx?= =?UTF-8?q?pedienteCrud=20e=20melhorias=20em=20sess=C3=A3o=20solene?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/sessao/views.py | 79 +++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 45 deletions(-) diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index 271f0b3d3..20a6b4a5e 100755 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -605,6 +605,7 @@ class ExpedienteMateriaCrud(MasterDetailCrud): layout_key = 'ExpedienteMateriaDetail' +# Orador das Explicações Pessoais class OradorCrud(MasterDetailCrud): model = Orador parent_field = 'sessao_plenaria' @@ -623,32 +624,6 @@ class OradorCrud(MasterDetailCrud): context.update({'subnav_template_name': 'sessao/subnav-solene.yaml'}) return context - class CreateView(MasterDetailCrud.CreateView): - - form_class = OradorForm - - def get_initial(self): - return {'id_sessao': self.kwargs['pk']} - - def get_success_url(self): - return reverse('sapl.sessao:orador_list', - kwargs={'pk': self.kwargs['pk']}) - -class UpdateView(MasterDetailCrud.UpdateView): - - form_class = OradorForm - - def get_initial(self): - initial = super().get_initial() - initial.update({'id_sessao': self.object.sessao_plenaria.id}) - initial.update({'numero': self.object.numero_ordem}) - - return initial - - -class OradorExpedienteCrud(OradorCrud): - model = OradorExpediente - class CreateView(MasterDetailCrud.CreateView): form_class = OradorForm @@ -669,17 +644,8 @@ class OradorExpedienteCrud(OradorCrud): return reverse('sapl.sessao:orador_list', kwargs={'pk': self.kwargs['pk']}) - - class UpdateView(MasterDetailCrud.UpdateView): - - form_class = OradorForm - - def get_initial(self): - initial = super().get_initial() - initial.update({'id_sessao': self.object.sessao_plenaria.id}) - initial.update({'numero':self.object.numero_ordem}) - - return initial + + class DetailView(MasterDetailCrud.DetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -690,8 +656,16 @@ class OradorExpedienteCrud(OradorCrud): context.update({'subnav_template_name': 'sessao/subnav-solene.yaml'}) return context - - class DetailView(MasterDetailCrud.DetailView): + + class UpdateView(MasterDetailCrud.UpdateView): + + form_class = OradorForm + + def get_initial(self): + initial = super().get_initial() + initial.update({'id_sessao': self.object.sessao_plenaria.id}) + initial.update({'numero': self.object.numero_ordem}) + return initial def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -747,6 +721,15 @@ class OradorExpedienteCrud(OradorCrud): return {'id_sessao': self.object.sessao_plenaria.id, 'numero': self.object.numero_ordem} + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + pk = context['root_pk'] + sessao = SessaoPlenaria.objects.get(id=pk) + tipo_sessao = sessao.tipo + if tipo_sessao.nome == "Solene": + context.update({'subnav_template_name': 'sessao/subnav-solene.yaml'}) + return context + class ListView(MasterDetailCrud.ListView): @@ -769,14 +752,13 @@ class OradorExpedienteCrud(OradorCrud): if tipo_sessao.nome == "Solene": context.update({'subnav_template_name': 'sessao/subnav-solene.yaml'}) return context - - - class UpdateView(MasterDetailCrud.UpdateView): + + class DeleteView(MasterDetailCrud.DeleteView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - pk = context['root_pk'] - sessao = SessaoPlenaria.objects.get(id=pk) + sessao_pk = context['root_pk'] + sessao = SessaoPlenaria.objects.get(id=sessao_pk) tipo_sessao = sessao.tipo if tipo_sessao.nome == "Solene": context.update({'subnav_template_name': 'sessao/subnav-solene.yaml'}) @@ -953,6 +935,14 @@ class SessaoCrud(Crud): namespace = self.model._meta.app_config.name return reverse('%s:%s' % (namespace, 'sessaoplenaria_list')) + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + sessao = context['object'] + tipo_sessao = sessao.tipo + if tipo_sessao.nome == "Solene": + context.update({'subnav_template_name': 'sessao/subnav-solene.yaml'}) + return context + class DetailView(Crud.DetailView): @property @@ -970,7 +960,6 @@ class SessaoCrud(Crud): tipo_sessao = sessao.tipo if tipo_sessao.nome == "Solene": context.update({'subnav_template_name': 'sessao/subnav-solene.yaml'}) - # self.layout_key = 'SessaoSolene' return context