Browse Source

Remove HorizontalRadioRenderer

pull/285/head
Edward Ribeiro 9 years ago
parent
commit
0a9c225944
  1. 6
      norma/forms.py
  2. 12
      parlamentares/forms.py
  3. 27
      protocoloadm/forms.py

6
norma/forms.py

@ -20,12 +20,6 @@ def get_esferas():
('M', 'Municipal')] ('M', 'Municipal')]
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class NormaJuridicaPesquisaForm(ModelForm): class NormaJuridicaPesquisaForm(ModelForm):
periodo_inicial = forms.DateField(label=u'Período Inicial', periodo_inicial = forms.DateField(label=u'Período Inicial',

12
parlamentares/forms.py

@ -1,3 +1,4 @@
from crispy_forms.bootstrap import InlineRadios
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Fieldset, Layout, Submit from crispy_forms.layout import HTML, Fieldset, Layout, Submit
from django import forms from django import forms
@ -17,19 +18,10 @@ class ParlamentaresListForm(forms.Form):
periodo = forms.CharField() periodo = forms.CharField()
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class ParlamentaresForm (ModelForm): class ParlamentaresForm (ModelForm):
ativo = forms.TypedChoiceField( ativo = forms.TypedChoiceField(
coerce=lambda x: x == 'True', coerce=lambda x: x == 'True',
choices=((True, 'Sim'), (False, 'Não')), choices=((True, 'Sim'), (False, 'Não')),
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer
)
) )
def clean_fotografia(self): def clean_fotografia(self):
@ -84,7 +76,7 @@ class ParlamentaresForm (ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
row1 = crispy_layout_mixin.to_row( row1 = crispy_layout_mixin.to_row(
[('nome_parlamentar', 8), ('ativo', 4)]) [('nome_parlamentar', 8), (InlineRadios('ativo'), 4)])
row2 = crispy_layout_mixin.to_row( row2 = crispy_layout_mixin.to_row(
[('nome_completo', 12)]) [('nome_completo', 12)])

27
protocoloadm/forms.py

@ -1,5 +1,6 @@
from datetime import date from datetime import date
from crispy_forms.bootstrap import InlineRadios
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Field, Fieldset, Layout, Submit from crispy_forms.layout import HTML, Button, Field, Fieldset, Layout, Submit
from django import forms from django import forms
@ -30,12 +31,6 @@ def get_range_anos():
+ [(year, year) for year in range(date.today().year, 1960, -1)] + [(year, year) for year in range(date.today().year, 1960, -1)]
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self]))
class ProtocoloForm(forms.Form): class ProtocoloForm(forms.Form):
YEARS = get_range_anos() YEARS = get_range_anos()
@ -213,15 +208,11 @@ class ProtocoloDocumentForm(ModelForm):
numeracao = forms.ChoiceField(required=True, numeracao = forms.ChoiceField(required=True,
choices=NUMERACAO_CHOICES, choices=NUMERACAO_CHOICES,
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer),
label='') label='')
tipo_protocolo = forms.ChoiceField(required=True, tipo_protocolo = forms.ChoiceField(required=True,
label=_('Tipo de Protocolo'), label=_('Tipo de Protocolo'),
choices=TIPOS_PROTOCOLO, choices=TIPOS_PROTOCOLO,)
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer))
tipo_documento = forms.ModelChoiceField( tipo_documento = forms.ModelChoiceField(
label=_('Tipo de Documento'), label=_('Tipo de Documento'),
@ -254,9 +245,9 @@ class ProtocoloDocumentForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
row1 = crispy_layout_mixin.to_row( row1 = crispy_layout_mixin.to_row(
[('numeracao', 12)]) [(InlineRadios('numeracao'), 12)])
row2 = crispy_layout_mixin.to_row( row2 = crispy_layout_mixin.to_row(
[('tipo_protocolo', 12)]) [(InlineRadios('tipo_protocolo'), 12)])
row3 = crispy_layout_mixin.to_row( row3 = crispy_layout_mixin.to_row(
[('tipo_documento', 6), [('tipo_documento', 6),
('num_paginas', 6)]) ('num_paginas', 6)])
@ -291,15 +282,11 @@ class ProtocoloMateriaForm(ModelForm):
numeracao = forms.ChoiceField(required=True, numeracao = forms.ChoiceField(required=True,
choices=NUMERACAO_CHOICES, choices=NUMERACAO_CHOICES,
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer),
label='') label='')
tipo_protocolo = forms.ChoiceField(required=True, tipo_protocolo = forms.ChoiceField(required=True,
label='Tipo de Protocolo', label='Tipo de Protocolo',
choices=TIPOS_PROTOCOLO, choices=TIPOS_PROTOCOLO,)
widget=forms.RadioSelect(
renderer=HorizontalRadioRenderer))
autor = forms.IntegerField(widget=forms.HiddenInput(), required=False) autor = forms.IntegerField(widget=forms.HiddenInput(), required=False)
@ -325,10 +312,10 @@ class ProtocoloMateriaForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
row1 = crispy_layout_mixin.to_row( row1 = crispy_layout_mixin.to_row(
[('numeracao', 12)]) [(InlineRadios('numeracao'), 12)])
row2 = crispy_layout_mixin.to_row( row2 = crispy_layout_mixin.to_row(
[('tipo_materia', 4), [('tipo_materia', 4),
('tipo_protocolo', 4), (InlineRadios('tipo_protocolo'), 4),
('numero_paginas', 4)]) ('numero_paginas', 4)])
row3 = crispy_layout_mixin.to_row( row3 = crispy_layout_mixin.to_row(
[('autor', 0), [('autor', 0),

Loading…
Cancel
Save