@ -262,16 +262,6 @@ class NotaForm(ModelForm):
class DispositivoSearchFragmentForm ( ModelForm ) :
class DispositivoSearchFragmentForm ( ModelForm ) :
pass
class VideForm ( ModelForm ) :
dispositivo_base = forms . ModelChoiceField (
queryset = Dispositivo . objects . all ( ) ,
widget = forms . HiddenInput ( ) )
dispositivo_ref = forms . ModelChoiceField (
queryset = Dispositivo . objects . all ( ) ,
widget = forms . HiddenInput ( ) )
tipo_ta = forms . ModelChoiceField (
tipo_ta = forms . ModelChoiceField (
label = _ ( ' Tipo do Texto Articulado ' ) ,
label = _ ( ' Tipo do Texto Articulado ' ) ,
@ -287,19 +277,63 @@ class VideForm(ModelForm):
ano_ta = forms . IntegerField (
ano_ta = forms . IntegerField (
label = _ ( ' Ano Texto Articulado ' ) , required = False )
label = _ ( ' Ano Texto Articulado ' ) , required = False )
texto = forms . CharField (
busca_dispositivo = forms . CharField (
label = ' ' ,
label = _ ( ' Buscar Dispositivo ' ) ,
widget = forms . Textarea ,
required = False )
required = False )
def __init__ ( self , * args , * * kwargs ) :
if ' fields_search ' in kwargs :
fields_search = kwargs [ ' fields_search ' ] . fields
fields_search . append (
Row (
to_column ( ( ' tipo_ta ' , 6 ) ) ,
to_column ( ( ' tipo_model ' , 6 ) ) ) )
fields_search . append (
Row (
to_column ( ( ' num_ta ' , 6 ) ) ,
to_column ( ( ' ano_ta ' , 6 ) ) ) )
fields_search . append (
Row ( to_column ( ( FieldWithButtons (
Field (
' busca_dispositivo ' ,
placeholder = _ ( ' Digite palavras, letras, '
' números ou algo '
' que estejam '
' no rótulo ou no texto. ' ) ) ,
StrictButton ( _ ( ' Buscar ' ) , css_class = ' btn-busca ' ) ) , 12 ) ) ) )
fields_search . append (
Row ( to_column (
( Div ( css_class = ' result-busca-dispositivo ' ) , 12 ) ) ) )
kwargs . pop ( ' fields_search ' )
if ' choice_model_type_foreignkey_in_extenal_views ' in kwargs :
ch = kwargs . pop ( ' choice_model_type_foreignkey_in_extenal_views ' )
if ' data ' in kwargs :
choice = ch ( kwargs [ ' data ' ] [ ' tipo_ta ' ] )
self . base_fields [ ' tipo_model ' ] . choices = choice
elif ' instance ' in kwargs and \
isinstance ( kwargs [ ' instance ' ] , Dispositivo ) :
choice = ch ( kwargs [ ' instance ' ] . ta . tipo_ta_id )
self . base_fields [ ' tipo_model ' ] . choices = choice
super ( DispositivoSearchFragmentForm , self ) . __init__ ( * args , * * kwargs )
class VideForm ( DispositivoSearchFragmentForm ) :
dispositivo_base = forms . ModelChoiceField (
queryset = Dispositivo . objects . all ( ) ,
widget = forms . HiddenInput ( ) )
dispositivo_ref = forms . ModelChoiceField (
queryset = Dispositivo . objects . all ( ) ,
widget = forms . HiddenInput ( ) )
tipo = forms . ModelChoiceField (
tipo = forms . ModelChoiceField (
label = TipoVide . _meta . verbose_name ,
label = TipoVide . _meta . verbose_name ,
queryset = TipoVide . objects . all ( ) ,
queryset = TipoVide . objects . all ( ) ,
required = True ,
required = True ,
error_messages = error_messages )
error_messages = error_messages )
busca_dispositivo = forms . CharField (
label = _ ( ' Buscar Dispositivo a Referenciar ' ) ,
required = False )
pk = forms . IntegerField ( widget = forms . HiddenInput ( ) ,
pk = forms . IntegerField ( widget = forms . HiddenInput ( ) ,
required = False )
required = False )
@ -337,24 +371,7 @@ class VideForm(ModelForm):
placeholder = _ ( ' Texto Adicional ao Vide ' ) ) , 12 ) ) ) ,
placeholder = _ ( ' Texto Adicional ao Vide ' ) ) , 12 ) ) ) ,
Row ( to_column ( ( buttons , 12 ) ) ) )
Row ( to_column ( ( buttons , 12 ) ) ) )
fields_search = Div (
kwargs [ ' fields_search ' ] = fields_search = Div ( )
Row (
to_column ( ( ' tipo_ta ' , 6 ) ) ,
to_column ( ( ' tipo_model ' , 6 ) ) ) ,
Row (
to_column ( ( ' num_ta ' , 6 ) ) ,
to_column ( ( ' ano_ta ' , 6 ) ) ) ,
Row ( to_column ( ( FieldWithButtons (
Field (
' busca_dispositivo ' ,
placeholder = _ ( ' Digite palavras, letras, '
' números ou algo '
' que estejam '
' no rótulo ou no texto. ' ) ) ,
StrictButton ( _ ( ' Buscar ' ) , css_class = ' btn-busca ' ) ) , 12 ) ) ) ,
Row ( to_column (
( Div ( css_class = ' container-busca ' ) , 12 ) ) )
)
self . helper = FormHelper ( )
self . helper = FormHelper ( )
self . helper . layout = Layout (
self . helper . layout = Layout (
@ -370,12 +387,6 @@ class VideForm(ModelForm):
)
)
)
)
if ' choice_model_type_foreignkey_in_extenal_views ' in kwargs :
ch = kwargs . pop ( ' choice_model_type_foreignkey_in_extenal_views ' )
if ' data ' in kwargs :
choice = ch ( kwargs [ ' data ' ] [ ' tipo_ta ' ] )
self . base_fields [ ' tipo_model ' ] . choices = choice
super ( VideForm , self ) . __init__ ( * args , * * kwargs )
super ( VideForm , self ) . __init__ ( * args , * * kwargs )
@ -581,8 +592,12 @@ class DispositivoEdicaoBasicaForm(ModelForm):
super ( DispositivoEdicaoBasicaForm , self ) . __init__ ( * args , * * kwargs )
super ( DispositivoEdicaoBasicaForm , self ) . __init__ ( * args , * * kwargs )
FIELD_NAME_MAPPING = {
' dispositivo_vigencia ' : ' dispositivo_ref ' ,
}
class DispositivoEdicaoVigenciaForm ( ModelForm ) :
class DispositivoEdicaoVigenciaForm ( DispositivoSearchFragment Form) :
inconstitucionalidade = forms . ChoiceField (
inconstitucionalidade = forms . ChoiceField (
label = Dispositivo . _meta . get_field (
label = Dispositivo . _meta . get_field (
@ -590,6 +605,11 @@ class DispositivoEdicaoVigenciaForm(ModelForm):
choices = utils . YES_NO_CHOICES ,
choices = utils . YES_NO_CHOICES ,
widget = forms . RadioSelect ( ) )
widget = forms . RadioSelect ( ) )
dispositivo_vigencia = forms . ModelChoiceField (
required = False ,
queryset = Dispositivo . objects . all ( ) ,
widget = forms . HiddenInput ( ) )
class Meta :
class Meta :
model = Dispositivo
model = Dispositivo
fields = [ ' inicio_vigencia ' ,
fields = [ ' inicio_vigencia ' ,
@ -597,9 +617,15 @@ class DispositivoEdicaoVigenciaForm(ModelForm):
' inicio_eficacia ' ,
' inicio_eficacia ' ,
' fim_eficacia ' ,
' fim_eficacia ' ,
' publicacao ' ,
' publicacao ' ,
' inconstitucionalidade '
' inconstitucionalidade ' ,
' dispositivo_vigencia '
]
]
def add_prefix ( self , field_name ) :
# look up field name; return original if not found
field_name = FIELD_NAME_MAPPING . get ( field_name , field_name )
return super ( DispositivoEdicaoVigenciaForm , self ) . add_prefix ( field_name )
def __init__ ( self , * args , * * kwargs ) :
def __init__ ( self , * args , * * kwargs ) :
layout = [ ]
layout = [ ]
@ -624,6 +650,7 @@ class DispositivoEdicaoVigenciaForm(ModelForm):
( ' fim_vigencia ' , 3 ) ,
( ' fim_vigencia ' , 3 ) ,
( ' inicio_eficacia ' , 3 ) ,
( ' inicio_eficacia ' , 3 ) ,
( ' fim_eficacia ' , 3 ) , ] )
( ' fim_eficacia ' , 3 ) , ] )
layout . append (
layout . append (
Fieldset ( _ ( ' Datas de Controle de Vigência ' ) ,
Fieldset ( _ ( ' Datas de Controle de Vigência ' ) ,
row_datas ,
row_datas ,
@ -631,9 +658,16 @@ class DispositivoEdicaoVigenciaForm(ModelForm):
self . helper = FormHelper ( )
self . helper = FormHelper ( )
self . helper . layout = SaplFormLayout (
self . helper . layout = SaplFormLayout (
* layout ,
label_cancel = _ ( ' Retornar para o Editor Sequencial ' ) )
label_cancel = _ ( ' Retornar para o Editor Sequencial ' ) )
self . helper . layout . fields + = layout
kwargs [ ' fields_search ' ] = fields_search = Div ( )
self . helper . layout . fields . append (
Fieldset ( _ ( ' Dispositivo de Vigência ' ) ,
fields_search ,
css_class = " col-md-12 dispositivo_vigencia_busca " ) )
super ( DispositivoEdicaoVigenciaForm , self ) . __init__ ( * args , * * kwargs )
super ( DispositivoEdicaoVigenciaForm , self ) . __init__ ( * args , * * kwargs )
pubs = Publicacao . objects . order_by (
pubs = Publicacao . objects . order_by (