Browse Source

Convert ButtonHolder to bootstrap FormAction

pull/202/head
Marcio Mazza 9 years ago
parent
commit
1b6b4a3a2b
  1. 8
      base/views.py
  2. 13
      comissoes/views.py
  3. 6
      compilacao/forms.py
  4. 54
      materia/views.py
  5. 7
      norma/views.py
  6. 111
      parlamentares/views.py
  7. 29
      protocoloadm/views.py
  8. 8
      sapl/layout.py
  9. 15
      sessao/views.py

8
base/views.py

@ -2,7 +2,7 @@ import os
from functools import lru_cache
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, ButtonHolder, Fieldset, Layout, Submit
from crispy_forms.layout import HTML, Fieldset, Layout
from django import forms
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
@ -12,6 +12,7 @@ from django.views.generic.edit import FormMixin
from vanilla import GenericView
import sapl
from sapl.layout import form_actions
from .models import CasaLegislativa
@ -161,10 +162,7 @@ class CasaLegislativaTabelaAuxForm(ModelForm):
row6,
row7,
row8,
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
)
super(CasaLegislativaTabelaAuxForm, self).__init__(*args, **kwargs)

13
comissoes/views.py

@ -1,5 +1,5 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit
from crispy_forms.layout import Fieldset, Layout
from django import forms
from django.contrib import messages
from django.core.urlresolvers import reverse
@ -10,6 +10,7 @@ from django.views.generic.edit import FormMixin
from vanilla import GenericView
import sapl
from sapl.layout import form_actions
from materia.models import Tramitacao
from parlamentares.models import Filiacao
from sapl.crud import build_crud
@ -154,10 +155,7 @@ class CadastrarComissaoForm(ModelForm):
row7,
row8
),
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
)
super(CadastrarComissaoForm, self).__init__(*args, **kwargs)
@ -302,10 +300,7 @@ class ParticipacaoCadastroForm(ModelForm):
'Formulário de Cadastro',
row1, row2, row3, row4
),
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
super(ParticipacaoCadastroForm, self).__init__(*args, **kwargs)

6
compilacao/forms.py

@ -229,7 +229,7 @@ class NotaForm(ModelForm):
('publicacao', 3),
('efetividade', 3),
(Button('submit', _('Salvar'),
css_class='button primary radius'), 3)
css_class='btn btn-primary'), 3)
])
self.helper = FormHelper()
@ -313,7 +313,7 @@ class VideForm(ModelForm):
Button(
'submit',
'Salvar',
css_class='button primary radius'), 12)))
css_class='btn btn-primary'), 12)))
), 4)),
to_column((
Div(
@ -331,7 +331,7 @@ class VideForm(ModelForm):
Button(
'buscar',
'Buscar',
css_class='button btn-busca radius'), 2))
css_class='btn btn-primary btn-busca'), 2))
),
to_column(

54
materia/views.py

@ -2,7 +2,7 @@ from datetime import date, datetime
from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import ButtonHolder, Column, Fieldset, Layout, Submit
from crispy_forms.layout import Column, Fieldset, Layout
from django import forms
from django.contrib import messages
from django.core.exceptions import ObjectDoesNotExist
@ -18,6 +18,7 @@ from django.views.generic.edit import FormMixin
from vanilla.views import GenericView
import sapl
from sapl.layout import form_actions
from comissoes.models import Comissao, Composicao
from compilacao.views import IntegracaoTaView
from norma.models import LegislacaoCitada, NormaJuridica, TipoNormaJuridica
@ -296,10 +297,7 @@ class FormularioSimplificadoForm(ModelForm):
'Identificação Básica',
row1, row2, row3, row4
),
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
)
super(FormularioSimplificadoForm, self).__init__(*args, **kwargs)
@ -375,10 +373,7 @@ class FormularioCadastroForm(ModelForm):
'indexacao',
'observacao'
),
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
)
super(FormularioCadastroForm, self).__init__(*args, **kwargs)
@ -472,10 +467,7 @@ class MateriaAnexadaForm(ModelForm):
Fieldset(
'Anexar Matéria',
row1, row2,
ButtonHolder(
Submit('submit', 'Anexar',
css_class='button primary')
)
form_actions()
)
)
super(MateriaAnexadaForm, self).__init__(
@ -654,10 +646,7 @@ class DespachoInicialFom(ModelForm):
Fieldset(
'Adicionar Despacho Inicial',
'comissao',
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
)
super(DespachoInicialFom, self).__init__(*args, **kwargs)
@ -823,10 +812,7 @@ class LegislacaoCitadaForm(ModelForm):
Fieldset(
'Incluir Legislação Citada',
row1, row2, row3, row4,
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
)
super(LegislacaoCitadaForm, self).__init__(*args, **kwargs)
@ -1001,10 +987,7 @@ class NumeracaoForm(ModelForm):
Fieldset(
'Incluir Numeração',
row1, row2,
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
)
super(NumeracaoForm, self).__init__(*args, **kwargs)
@ -1146,10 +1129,7 @@ class DocumentoAcessorioForm(ModelForm):
Fieldset(
'Incluir Documento Acessório',
row1, row2, row3,
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
)
super(DocumentoAcessorioForm, self).__init__(*args, **kwargs)
@ -1452,10 +1432,7 @@ class TramitacaoForm(ModelForm):
Fieldset('Incluir Tramitação',
row1, row2, row3, row4, row5,
),
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
super(TramitacaoForm, self).__init__(
*args, **kwargs)
@ -1791,11 +1768,7 @@ class ProposicaoForm(ModelForm):
[('texto_original', 10)])
row4.append(
Column(
ButtonHolder(
Submit('sumbmit', 'Salvar',
css_class='button primary')
), css_class='columns large-2'))
Column(form_actions(), css_class='columns large-2'))
self.helper = FormHelper()
self.helper.layout = Layout(
@ -1971,10 +1944,7 @@ class MateriaLegislativaPesquisaForm(forms.Form):
self.helper.layout = Layout(
Fieldset('Pesquisa Básica',
row1, row2, row3, row4, row5, row6, row7),
ButtonHolder(
Submit('submit', 'Pesquisar',
css_class='button primary')
)
form_actions(save_label='Pesquisar')
)
super(MateriaLegislativaPesquisaForm, self).__init__(
*args, **kwargs)

7
norma/views.py

@ -2,7 +2,7 @@ from datetime import datetime
from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit
from crispy_forms.layout import Fieldset, Layout
from django import forms
from django.core.exceptions import ObjectDoesNotExist
from django.forms import ModelForm
@ -13,6 +13,7 @@ from django.views.generic.edit import FormMixin
from vanilla.views import GenericView
import sapl
from sapl.layout import form_actions
from compilacao.views import IntegracaoTaView
from materia.models import MateriaLegislativa, TipoMateriaLegislativa
from sapl.crud import build_crud
@ -163,9 +164,7 @@ class NormaJuridicaForm(ModelForm):
Fieldset('Cadastro de Norma Jurídica',
Fieldset('Identificação Básica',
row1, row2, row3, row4, row5, row6, row7, row8),
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary'))
form_actions()
)
)
super(NormaJuridicaForm, self).__init__(*args, **kwargs)

111
parlamentares/views.py

@ -2,7 +2,7 @@ import os
from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, ButtonHolder, Fieldset, Layout, Submit
from crispy_forms.layout import HTML, Fieldset, Layout, Submit
from django import forms
from django.contrib import messages
from django.core.urlresolvers import reverse
@ -14,6 +14,7 @@ from django.views.generic.edit import FormMixin
from vanilla import GenericView
import sapl
from sapl.layout import form_actions
from sapl.crud import build_crud
from .models import (CargoMesa, Coligacao, ComposicaoMesa, Dependente,
@ -383,10 +384,7 @@ class ParlamentaresForm (ModelForm):
value="Remover Foto"/>
{% endif %}""", ),
row14,
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary'),
))
form_actions())
)
super(ParlamentaresForm, self).__init__(
@ -399,12 +397,10 @@ class ParlamentaresEditForm(ParlamentaresForm):
super(ParlamentaresEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = ButtonHolder(
Submit('salvar', 'Salvar',
css_class='button primary'),
self.helper.layout[0][-1:] = form_actions(more=[
HTML(' '),
Submit('excluir', 'Excluir',
css_class='button primary'),)
css_class='btn btn-primary')])
class ParlamentaresCadastroView(FormMixin, GenericView):
@ -521,10 +517,7 @@ class DependenteForm(ModelForm):
self.helper.layout = Layout(
Fieldset('Cadastro de Dependentes',
row1, row2, row3,
ButtonHolder(
Submit('Salvar', 'Salvar',
css_class='button primary'),
))
form_actions())
)
super(DependenteForm, self).__init__(
@ -537,12 +530,10 @@ class DependenteEditForm(DependenteForm):
super(DependenteEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = ButtonHolder(
Submit('Salvar', 'Salvar',
css_class='button primary'),
self.helper.layout[0][-1:] = form_actions(more=[
HTML(' '),
Submit('Excluir', 'Excluir',
css_class='button primary'),)
Submit('excluir', 'Excluir',
css_class='btn btn-primary')])
class ParlamentaresDependentesView(FormMixin, GenericView):
@ -643,10 +634,10 @@ class MesaDiretoraView(FormMixin, GenericView):
messages.add_message(request, messages.INFO, mensagem)
return self.render_to_response(
{'legislaturas': Legislatura.objects.all(
).order_by('-data_inicio'),
'legislatura_selecionada': Legislatura.objects.last(),
'cargos_vagos': CargoMesa.objects.all()})
{'legislaturas': Legislatura.objects.all(
).order_by('-data_inicio'),
'legislatura_selecionada': Legislatura.objects.last(),
'cargos_vagos': CargoMesa.objects.all()})
def get(self, request, *args, **kwargs):
@ -671,16 +662,16 @@ class MesaDiretoraView(FormMixin, GenericView):
return self.render_to_response(
{'legislaturas': Legislatura.objects.all(
).order_by('-data_inicio'),
'legislatura_selecionada': Legislatura.objects.last(),
'sessoes': SessaoLegislativa.objects.filter(
legislatura=Legislatura.objects.last()),
'sessao_selecionada': SessaoLegislativa.objects.filter(
legislatura=Legislatura.objects.last()).first(),
'composicao_mesa': mesa,
'parlamentares': parlamentares_vagos,
'cargos_vagos': cargos_vagos
})
).order_by('-data_inicio'),
'legislatura_selecionada': Legislatura.objects.last(),
'sessoes': SessaoLegislativa.objects.filter(
legislatura=Legislatura.objects.last()),
'sessao_selecionada': SessaoLegislativa.objects.filter(
legislatura=Legislatura.objects.last()).first(),
'composicao_mesa': mesa,
'parlamentares': parlamentares_vagos,
'cargos_vagos': cargos_vagos
})
def post(self, request, *args, **kwargs):
if 'Incluir' in request.POST:
@ -708,10 +699,10 @@ class MesaDiretoraView(FormMixin, GenericView):
if 'composicao_mesa' in request.POST:
ids = request.POST['composicao_mesa'].split(':')
composicao = ComposicaoMesa.objects.get(
sessao_legislativa_id=int(request.POST['sessao']),
parlamentar_id=int(ids[0]),
cargo_id=int(ids[1])
)
sessao_legislativa_id=int(request.POST['sessao']),
parlamentar_id=int(ids[0]),
cargo_id=int(ids[1])
)
composicao.delete()
return self.form_valid(form=None)
else:
@ -731,17 +722,17 @@ class MesaDiretoraView(FormMixin, GenericView):
parlamentares_ocupados))
return self.render_to_response(
{'legislaturas': Legislatura.objects.all(
).order_by('-data_inicio'),
'legislatura_selecionada': Legislatura.objects.get(
id=int(request.POST['legislatura'])),
'sessoes': SessaoLegislativa.objects.filter(
legislatura_id=int(request.POST['legislatura'])),
'sessao_selecionada': SessaoLegislativa.objects.get(
id=int(request.POST['sessao'])),
'composicao_mesa': mesa,
'parlamentares': parlamentares_vagos,
'cargos_vagos': cargos_vagos
})
).order_by('-data_inicio'),
'legislatura_selecionada': Legislatura.objects.get(
id=int(request.POST['legislatura'])),
'sessoes': SessaoLegislativa.objects.filter(
legislatura_id=int(request.POST['legislatura'])),
'sessao_selecionada': SessaoLegislativa.objects.get(
id=int(request.POST['sessao'])),
'composicao_mesa': mesa,
'parlamentares': parlamentares_vagos,
'cargos_vagos': cargos_vagos
})
class FiliacaoForm(ModelForm):
@ -762,10 +753,7 @@ class FiliacaoForm(ModelForm):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Adicionar Filiação', row1,
ButtonHolder(
Submit('Salvar', 'Salvar',
css_class='button primary'),
))
form_actions())
)
super(FiliacaoForm, self).__init__(
@ -778,12 +766,10 @@ class FiliacaoEditForm(FiliacaoForm):
super(FiliacaoEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = ButtonHolder(
Submit('Salvar', 'Salvar',
css_class='button primary'),
self.helper.layout[0][-1:] = form_actions(more=[
HTML(' '),
Submit('Excluir', 'Excluir',
css_class='button primary'),)
Submit('excluir', 'Excluir',
css_class='btn btn-primary')])
class FiliacaoView(FormMixin, GenericView):
@ -1050,10 +1036,7 @@ class MandatoForm(ModelForm):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Adicionar Mandato', row1, row2, row3,
ButtonHolder(
Submit('Salvar', 'Salvar',
css_class='button primary'),
))
form_actions())
)
super(MandatoForm, self).__init__(
@ -1066,12 +1049,10 @@ class MandatoEditForm(MandatoForm):
super(MandatoEditForm, self).__init__(
*args, **kwargs)
self.helper.layout[0][-1:] = ButtonHolder(
Submit('Salvar', 'Salvar',
css_class='button primary'),
self.helper.layout[0][-1:] = form_actions(more=[
HTML(' '),
Submit('Excluir', 'Excluir',
css_class='button primary'),)
Submit('excluir', 'Excluir',
css_class='btn btn-primary')])
class MandatoView(FormMixin, GenericView):

29
protocoloadm/views.py

@ -2,8 +2,7 @@ from datetime import date, datetime
from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import (HTML, ButtonHolder, Field, Fieldset, Layout,
Submit)
from crispy_forms.layout import (HTML, Field, Fieldset, Layout)
from django import forms
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
@ -20,6 +19,7 @@ from django.views.generic.edit import FormMixin
from vanilla import GenericView
import sapl
from sapl.layout import form_actions
from materia.models import Proposicao, TipoMateriaLegislativa
from sapl.crud import build_crud
@ -330,10 +330,7 @@ class AnularProcoloAdmForm(forms.Form):
row1,
row2,
HTML(" "),
ButtonHolder(Submit('submit', 'Anular',
css_class='button primary'
)
)
form_actions(save_label='Anular')
)
)
super(AnularProcoloAdmForm, self).__init__(
@ -460,10 +457,7 @@ class ProtocoloDocumentForm(forms.Form):
row5,
row6,
HTML(" "),
ButtonHolder(Submit('submit', 'Protocolar Documento',
css_class='button primary'
)
)
form_actions(save_label='Protocolar Documento')
)
)
super(ProtocoloDocumentForm, self).__init__(
@ -576,10 +570,7 @@ class ProtocoloMateriaForm(forms.Form):
row4,
row5,
HTML(" "),
ButtonHolder(Submit('submit', 'Protocolar Matéria',
css_class='button primary'
)
)
form_actions(save_label='Protocolar Matéria')
)
)
super(ProtocoloMateriaForm, self).__init__(
@ -887,10 +878,7 @@ class ModelFormDocumentoAcessorioAdministrativo(ModelForm):
'autor',
'arquivo',
'assunto',
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
)
super(ModelFormDocumentoAcessorioAdministrativo, self).__init__(
@ -1002,10 +990,7 @@ class TramitacaoAdmForm(ModelForm):
'data_fim_prazo',
'texto'),
Field('documento', type="hidden"),
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
super(TramitacaoAdmForm, self).__init__(
*args, **kwargs)

8
sapl/layout.py

@ -22,11 +22,15 @@ def to_fieldsets(fields):
yield field
def form_actions(more=[], save_label=_('Salvar')):
return FormActions(
Submit('save', save_label, css_class='btn btn-primary'), *more)
class SaplFormLayout(Layout):
def __init__(self, *fields):
buttons = FormActions(
Submit('save', _('Enviar'), css_class='btn btn-primary '),
buttons = form_actions(
HTML('<a href="{{ view.cancel_url }}"'
' class="btn btn-inverse">%s</a>' % _('Cancelar')))
_fields = list(to_fieldsets(fields)) + [to_row([(buttons, 12)])]

15
sessao/views.py

@ -2,7 +2,7 @@ from datetime import datetime
from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import ButtonHolder, Column, Fieldset, Layout, Submit
from crispy_forms.layout import Column, Fieldset, Layout
from django import forms
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
@ -15,6 +15,7 @@ from django.views.generic.edit import FormMixin
from rest_framework import generics
import sapl
from sapl.layout import form_actions
from materia.models import (Autoria, DocumentoAcessorio,
TipoMateriaLegislativa, Tramitacao)
from norma.models import NormaJuridica
@ -2410,10 +2411,7 @@ class SessaoForm(ModelForm):
row3,
row4,
row5,
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
form_actions()
)
)
super(SessaoForm, self).__init__(*args, **kwargs)
@ -2505,12 +2503,7 @@ class AcompanharMateriaForm(ModelForm):
row1 = sapl.layout.to_row([('email', 10)])
row1.append(
Column(
ButtonHolder(
Submit('Submit', 'Cadastrar',
css_class='button primary')
), css_class='columns-large-2'
)
Column(form_actions(save_label='Cadastrar'), css_class='columns-large-2')
)
self.helper = FormHelper()

Loading…
Cancel
Save