@ -1,7 +1,9 @@
from datetime import datetime
from django . core . urlresolvers import reverse
from django . shortcuts import redirect
from django . views . generic import FormView , ListView
from django . views . generic . base import RedirectView
from sapl . compilacao . views import IntegracaoTaView
from sapl . crud . base import RP_DETAIL , RP_LIST , Crud , CrudAux , make_pagination
@ -10,9 +12,8 @@ from sapl.norma.forms import NormaJuridicaForm
from . forms import NormaJuridicaPesquisaForm
from . models import AssuntoNorma , NormaJuridica , TipoNormaJuridica
# LegislacaoCitadaCrud = Crud.build(LegislacaoCitada, '')
# LegislacaoCitadaCrud = Crud.build(LegislacaoCitada, '')
AssuntoNormaCrud = CrudAux . build ( AssuntoNorma , ' assunto_norma_juridica ' ,
list_field_names = [ ' assunto ' , ' descricao ' ] )
@ -27,6 +28,38 @@ class NormaCrud(Crud):
help_path = ' norma_juridica '
public = [ RP_LIST , RP_DETAIL ]
class BaseMixin ( Crud . BaseMixin ) :
list_field_names = [ ' tipo ' , ' numero ' , ' ano ' , ' ementa ' ]
@property
def list_url ( self ) :
return ' '
@property
def search_url ( self ) :
namespace = self . model . _meta . app_config . name
return reverse ( ' %s : %s ' % ( namespace , ' norma_pesquisa ' ) )
class CreateView ( Crud . CreateView ) :
form_class = NormaJuridicaForm
@property
def cancel_url ( self ) :
return self . search_url
@property
def layout_key ( self ) :
return ' NormaJuridicaCreate '
class ListView ( Crud . ListView , RedirectView ) :
def get_redirect_url ( self , * args , * * kwargs ) :
namespace = self . model . _meta . app_config . name
return reverse ( ' %s : %s ' % ( namespace , ' norma_pesquisa ' ) )
def get ( self , request , * args , * * kwargs ) :
return RedirectView . get ( self , request , * args , * * kwargs )
class UpdateView ( Crud . UpdateView ) :
form_class = NormaJuridicaForm
@ -42,16 +75,6 @@ class NormaCrud(Crud):
self . initial [ ' numero_materia ' ] = norma . materia . numero
return self . initial . copy ( )
class CreateView ( Crud . CreateView ) :
form_class = NormaJuridicaForm
@property
def layout_key ( self ) :
return ' NormaJuridicaCreate '
class BaseMixin ( Crud . BaseMixin ) :
list_field_names = [ ' tipo ' , ' numero ' , ' ano ' , ' ementa ' ]
class NormaPesquisaView ( FormView ) :
template_name = " norma/pesquisa.html "