From 88e73ade510297b46ad17fc3e1e5af74370aff13 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 28 Apr 2016 12:14:36 -0300 Subject: [PATCH] =?UTF-8?q?Init=20crud=20legisla=C3=A7=C3=A3o=20citada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- materia/urls.py | 3 ++- materia/views.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/materia/urls.py b/materia/urls.py index 9c330600a..01c0d6a05 100644 --- a/materia/urls.py +++ b/materia/urls.py @@ -27,7 +27,8 @@ urlpatterns = [ DespachoInicialCrud.get_urls() + NumeracaoCrud.get_urls() + LegislacaoCitadaCrud.get_urls() + - TramitacaoCrud.get_urls())), + TramitacaoCrud.get_urls() + + LegislacaoCitadaCrud.get_urls())), # Integração com Compilação url(r'^materia/(?P[0-9]+)/ta$', diff --git a/materia/views.py b/materia/views.py index 1bec66767..8656864fd 100644 --- a/materia/views.py +++ b/materia/views.py @@ -151,6 +151,34 @@ class LegislacaoCitadaCrud(MasterDetailCrud): return 'LegislacaoCitadaDetail' +class LegislacaoCitadaCrud(MasterDetailCrud): + model = LegislacaoCitada + parent_field = 'materia' + help_path = '' + + class BaseMixin(MasterDetailCrud.BaseMixin): + list_field_names = ['norma', 'disposicoes'] + + class CreateView(MasterDetailCrud.CreateView): + form_class = LegislacaoCitadaForm + + class UpdateView(MasterDetailCrud.UpdateView): + form_class = LegislacaoCitadaForm + + def get_initial(self): + self.initial['tipo_norma'] = self.object.norma.tipo.id + self.initial['numero_norma'] = self.object.norma.numero + self.initial['ano_norma'] = self.object.norma.ano + + return self.initial + + class DetailView(MasterDetailCrud.DetailView): + + @property + def layout_key(self): + return 'LegislacaoCitadaDetail' + + class NumeracaoCrud(MasterDetailCrud): model = Numeracao parent_field = 'materia'