From 0a9c22594484a8700a66c2f28b8422c8122fed03 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Fri, 18 Mar 2016 18:43:35 -0300 Subject: [PATCH] Remove HorizontalRadioRenderer --- norma/forms.py | 6 ------ parlamentares/forms.py | 12 ++---------- protocoloadm/forms.py | 27 +++++++-------------------- 3 files changed, 9 insertions(+), 36 deletions(-) diff --git a/norma/forms.py b/norma/forms.py index 8b25e91a7..4199b26ff 100644 --- a/norma/forms.py +++ b/norma/forms.py @@ -20,12 +20,6 @@ def get_esferas(): ('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): periodo_inicial = forms.DateField(label=u'Período Inicial', diff --git a/parlamentares/forms.py b/parlamentares/forms.py index 1ae31cef3..542e1d4fe 100644 --- a/parlamentares/forms.py +++ b/parlamentares/forms.py @@ -1,3 +1,4 @@ +from crispy_forms.bootstrap import InlineRadios from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Fieldset, Layout, Submit from django import forms @@ -17,19 +18,10 @@ class ParlamentaresListForm(forms.Form): 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): ativo = forms.TypedChoiceField( coerce=lambda x: x == 'True', choices=((True, 'Sim'), (False, 'Não')), - widget=forms.RadioSelect( - renderer=HorizontalRadioRenderer - ) ) def clean_fotografia(self): @@ -84,7 +76,7 @@ class ParlamentaresForm (ModelForm): def __init__(self, *args, **kwargs): row1 = crispy_layout_mixin.to_row( - [('nome_parlamentar', 8), ('ativo', 4)]) + [('nome_parlamentar', 8), (InlineRadios('ativo'), 4)]) row2 = crispy_layout_mixin.to_row( [('nome_completo', 12)]) diff --git a/protocoloadm/forms.py b/protocoloadm/forms.py index dc87f53ac..ce3dd1c99 100644 --- a/protocoloadm/forms.py +++ b/protocoloadm/forms.py @@ -1,5 +1,6 @@ from datetime import date +from crispy_forms.bootstrap import InlineRadios from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Button, Field, Fieldset, Layout, Submit from django import forms @@ -30,12 +31,6 @@ def get_range_anos(): + [(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): YEARS = get_range_anos() @@ -213,15 +208,11 @@ class ProtocoloDocumentForm(ModelForm): numeracao = forms.ChoiceField(required=True, choices=NUMERACAO_CHOICES, - widget=forms.RadioSelect( - renderer=HorizontalRadioRenderer), label='') tipo_protocolo = forms.ChoiceField(required=True, label=_('Tipo de Protocolo'), - choices=TIPOS_PROTOCOLO, - widget=forms.RadioSelect( - renderer=HorizontalRadioRenderer)) + choices=TIPOS_PROTOCOLO,) tipo_documento = forms.ModelChoiceField( label=_('Tipo de Documento'), @@ -254,9 +245,9 @@ class ProtocoloDocumentForm(ModelForm): def __init__(self, *args, **kwargs): row1 = crispy_layout_mixin.to_row( - [('numeracao', 12)]) + [(InlineRadios('numeracao'), 12)]) row2 = crispy_layout_mixin.to_row( - [('tipo_protocolo', 12)]) + [(InlineRadios('tipo_protocolo'), 12)]) row3 = crispy_layout_mixin.to_row( [('tipo_documento', 6), ('num_paginas', 6)]) @@ -291,15 +282,11 @@ class ProtocoloMateriaForm(ModelForm): numeracao = forms.ChoiceField(required=True, choices=NUMERACAO_CHOICES, - widget=forms.RadioSelect( - renderer=HorizontalRadioRenderer), label='') tipo_protocolo = forms.ChoiceField(required=True, label='Tipo de Protocolo', - choices=TIPOS_PROTOCOLO, - widget=forms.RadioSelect( - renderer=HorizontalRadioRenderer)) + choices=TIPOS_PROTOCOLO,) autor = forms.IntegerField(widget=forms.HiddenInput(), required=False) @@ -325,10 +312,10 @@ class ProtocoloMateriaForm(ModelForm): def __init__(self, *args, **kwargs): row1 = crispy_layout_mixin.to_row( - [('numeracao', 12)]) + [(InlineRadios('numeracao'), 12)]) row2 = crispy_layout_mixin.to_row( [('tipo_materia', 4), - ('tipo_protocolo', 4), + (InlineRadios('tipo_protocolo'), 4), ('numero_paginas', 4)]) row3 = crispy_layout_mixin.to_row( [('autor', 0),