Browse Source

Change Form Parlamentar Name

pull/11/merge
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
7dfd36f575
  1. 18
      parlamentares/views.py

18
parlamentares/views.py

@ -1,8 +1,7 @@
import sapl import sapl
from re import sub from re import sub
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import (HTML, ButtonHolder, Column, Fieldset, Layout, from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit
Submit)
from django import forms from django import forms
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms import ModelForm from django.forms import ModelForm
@ -148,7 +147,7 @@ tipo_militar_crud = build_crud(
]) ])
class ParlamentaresForm(forms.Form): class ParlamentaresListForm(forms.Form):
periodo = forms.CharField() periodo = forms.CharField()
@ -156,7 +155,7 @@ class ParlamentaresView(GenericView):
template_name = "parlamentares/parlamentares_list.html" template_name = "parlamentares/parlamentares_list.html"
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
form = ParlamentaresForm() form = ParlamentaresListForm()
legislaturas = Legislatura.objects.all().order_by( legislaturas = Legislatura.objects.all().order_by(
'-data_inicio', '-data_fim') '-data_inicio', '-data_fim')
return self.render_to_response( return self.render_to_response(
@ -167,7 +166,7 @@ class ParlamentaresView(GenericView):
'filiacao': Filiacao.objects.all()}) 'filiacao': Filiacao.objects.all()})
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = ParlamentaresForm(request.POST) form = ParlamentaresListForm(request.POST)
return self.render_to_response( return self.render_to_response(
{'legislaturas': Legislatura.objects.all().order_by( {'legislaturas': Legislatura.objects.all().order_by(
'-data_inicio', '-data_fim'), '-data_inicio', '-data_fim'),
@ -176,13 +175,14 @@ class ParlamentaresView(GenericView):
'form': form, 'form': form,
'filiacao': Filiacao.objects.all()}) 'filiacao': Filiacao.objects.all()})
class HorizontalRadioRenderer(forms.RadioSelect.renderer): class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self): def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in 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')),
@ -315,7 +315,8 @@ class ParlamentaresCadastroView(FormMixin, GenericView):
return self.form_valid(form) return self.form_valid(form)
else: else:
return self.render_to_response({'form': form, 'legislatura_id': pk}) return self.render_to_response(
{'form': form, 'legislatura_id': pk})
class ParlamentaresEditarView(FormMixin, GenericView): class ParlamentaresEditarView(FormMixin, GenericView):
@ -350,4 +351,5 @@ class ParlamentaresEditarView(FormMixin, GenericView):
return self.form_valid(form) return self.form_valid(form)
else: else:
return self.render_to_response({'form': form, 'legislatura_id': pk}) return self.render_to_response(
{'form': form, 'legislatura_id': pk})

Loading…
Cancel
Save