Browse Source

Refatora app Norma para adequar-se ao Crud

pull/675/head
LeandroRoberto 8 years ago
parent
commit
c9322767bd
  1. 34
      sapl/norma/views.py

34
sapl/norma/views.py

@ -5,7 +5,8 @@ from django.views.generic import FormView, ListView
from sapl.compilacao.views import IntegracaoTaView from sapl.compilacao.views import IntegracaoTaView
from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView,
CrudDeleteView, CrudUpdateView, make_pagination) CrudDeleteView, CrudUpdateView, make_pagination,
CrudAux, RP_LIST, RP_DETAIL)
from sapl.utils import permissoes_norma from sapl.utils import permissoes_norma
from .forms import NormaJuridicaForm, NormaJuridicaPesquisaForm from .forms import NormaJuridicaForm, NormaJuridicaPesquisaForm
@ -15,31 +16,22 @@ from .models import (AssuntoNorma, LegislacaoCitada, NormaJuridica,
LegislacaoCitadaCrud = Crud.build(LegislacaoCitada, '') LegislacaoCitadaCrud = Crud.build(LegislacaoCitada, '')
class AssuntoNormaCrud(Crud): AssuntoNormaCrud = CrudAux.build(AssuntoNorma, 'assunto_norma_juridica',
model = AssuntoNorma list_field_names=['assunto', 'descricao'])
help_path = 'assunto_norma_juridica'
class BaseMixin(CrudBaseMixin):
permission_required = permissoes_norma()
list_field_names = ['assunto', 'descricao']
TipoNormaCrud = CrudAux.build(
class TipoNormaCrud(Crud): TipoNormaJuridica, 'tipo_norma_juridica',
model = TipoNormaJuridica list_field_names=['equivalente_lexml', 'sigla', 'descricao'])
help_path = 'tipo_norma_juridica'
class BaseMixin(CrudBaseMixin):
permission_required = permissoes_norma()
list_field_names = ['equivalente_lexml', 'sigla', 'descricao']
class NormaCrud(Crud): class NormaCrud(Crud):
model = NormaJuridica model = NormaJuridica
help_path = 'norma_juridica' help_path = 'norma_juridica'
public = [RP_LIST, RP_DETAIL]
class UpdateView(CrudUpdateView): class UpdateView(Crud.UpdateView):
form_class = NormaJuridicaForm form_class = NormaJuridicaForm
permission_required = permissoes_norma()
@property @property
def layout_key(self): def layout_key(self):
@ -53,18 +45,14 @@ class NormaCrud(Crud):
self.initial['numero_materia'] = norma.materia.numero self.initial['numero_materia'] = norma.materia.numero
return self.initial.copy() return self.initial.copy()
class CreateView(CrudCreateView): class CreateView(Crud.CreateView):
form_class = NormaJuridicaForm form_class = NormaJuridicaForm
permission_required = permissoes_norma()
@property @property
def layout_key(self): def layout_key(self):
return 'NormaJuridicaCreate' return 'NormaJuridicaCreate'
class DeleteView(CrudDeleteView): class BaseMixin(Crud.BaseMixin):
permission_required = permissoes_norma()
class BaseMixin(CrudBaseMixin):
list_field_names = ['tipo', 'numero', 'ano', 'ementa'] list_field_names = ['tipo', 'numero', 'ano', 'ementa']

Loading…
Cancel
Save