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

13
comissoes/views.py

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

6
compilacao/forms.py

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

54
materia/views.py

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

7
norma/views.py

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

53
parlamentares/views.py

@ -2,7 +2,7 @@ import os
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, Fieldset, Layout, Submit from crispy_forms.layout import HTML, Fieldset, Layout, Submit
from django import forms from django import forms
from django.contrib import messages from django.contrib import messages
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
@ -14,6 +14,7 @@ from django.views.generic.edit import FormMixin
from vanilla import GenericView from vanilla import GenericView
import sapl import sapl
from sapl.layout import form_actions
from sapl.crud import build_crud from sapl.crud import build_crud
from .models import (CargoMesa, Coligacao, ComposicaoMesa, Dependente, from .models import (CargoMesa, Coligacao, ComposicaoMesa, Dependente,
@ -383,10 +384,7 @@ class ParlamentaresForm (ModelForm):
value="Remover Foto"/> value="Remover Foto"/>
{% endif %}""", ), {% endif %}""", ),
row14, row14,
ButtonHolder( form_actions())
Submit('submit', 'Salvar',
css_class='button primary'),
))
) )
super(ParlamentaresForm, self).__init__( super(ParlamentaresForm, self).__init__(
@ -399,12 +397,10 @@ class ParlamentaresEditForm(ParlamentaresForm):
super(ParlamentaresEditForm, self).__init__( super(ParlamentaresEditForm, self).__init__(
*args, **kwargs) *args, **kwargs)
self.helper.layout[0][-1:] = ButtonHolder( self.helper.layout[0][-1:] = form_actions(more=[
Submit('salvar', 'Salvar',
css_class='button primary'),
HTML(' '), HTML(' '),
Submit('excluir', 'Excluir', Submit('excluir', 'Excluir',
css_class='button primary'),) css_class='btn btn-primary')])
class ParlamentaresCadastroView(FormMixin, GenericView): class ParlamentaresCadastroView(FormMixin, GenericView):
@ -521,10 +517,7 @@ class DependenteForm(ModelForm):
self.helper.layout = Layout( self.helper.layout = Layout(
Fieldset('Cadastro de Dependentes', Fieldset('Cadastro de Dependentes',
row1, row2, row3, row1, row2, row3,
ButtonHolder( form_actions())
Submit('Salvar', 'Salvar',
css_class='button primary'),
))
) )
super(DependenteForm, self).__init__( super(DependenteForm, self).__init__(
@ -537,12 +530,10 @@ class DependenteEditForm(DependenteForm):
super(DependenteEditForm, self).__init__( super(DependenteEditForm, self).__init__(
*args, **kwargs) *args, **kwargs)
self.helper.layout[0][-1:] = ButtonHolder( self.helper.layout[0][-1:] = form_actions(more=[
Submit('Salvar', 'Salvar',
css_class='button primary'),
HTML(' '), HTML(' '),
Submit('Excluir', 'Excluir', Submit('excluir', 'Excluir',
css_class='button primary'),) css_class='btn btn-primary')])
class ParlamentaresDependentesView(FormMixin, GenericView): class ParlamentaresDependentesView(FormMixin, GenericView):
@ -762,10 +753,7 @@ class FiliacaoForm(ModelForm):
self.helper = FormHelper() self.helper = FormHelper()
self.helper.layout = Layout( self.helper.layout = Layout(
Fieldset('Adicionar Filiação', row1, Fieldset('Adicionar Filiação', row1,
ButtonHolder( form_actions())
Submit('Salvar', 'Salvar',
css_class='button primary'),
))
) )
super(FiliacaoForm, self).__init__( super(FiliacaoForm, self).__init__(
@ -778,12 +766,10 @@ class FiliacaoEditForm(FiliacaoForm):
super(FiliacaoEditForm, self).__init__( super(FiliacaoEditForm, self).__init__(
*args, **kwargs) *args, **kwargs)
self.helper.layout[0][-1:] = ButtonHolder( self.helper.layout[0][-1:] = form_actions(more=[
Submit('Salvar', 'Salvar',
css_class='button primary'),
HTML(' '), HTML(' '),
Submit('Excluir', 'Excluir', Submit('excluir', 'Excluir',
css_class='button primary'),) css_class='btn btn-primary')])
class FiliacaoView(FormMixin, GenericView): class FiliacaoView(FormMixin, GenericView):
@ -1050,10 +1036,7 @@ class MandatoForm(ModelForm):
self.helper = FormHelper() self.helper = FormHelper()
self.helper.layout = Layout( self.helper.layout = Layout(
Fieldset('Adicionar Mandato', row1, row2, row3, Fieldset('Adicionar Mandato', row1, row2, row3,
ButtonHolder( form_actions())
Submit('Salvar', 'Salvar',
css_class='button primary'),
))
) )
super(MandatoForm, self).__init__( super(MandatoForm, self).__init__(
@ -1066,12 +1049,10 @@ class MandatoEditForm(MandatoForm):
super(MandatoEditForm, self).__init__( super(MandatoEditForm, self).__init__(
*args, **kwargs) *args, **kwargs)
self.helper.layout[0][-1:] = ButtonHolder( self.helper.layout[0][-1:] = form_actions(more=[
Submit('Salvar', 'Salvar',
css_class='button primary'),
HTML(' '), HTML(' '),
Submit('Excluir', 'Excluir', Submit('excluir', 'Excluir',
css_class='button primary'),) css_class='btn btn-primary')])
class MandatoView(FormMixin, GenericView): class MandatoView(FormMixin, GenericView):

29
protocoloadm/views.py

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

8
sapl/layout.py

@ -22,11 +22,15 @@ def to_fieldsets(fields):
yield field yield field
def form_actions(more=[], save_label=_('Salvar')):
return FormActions(
Submit('save', save_label, css_class='btn btn-primary'), *more)
class SaplFormLayout(Layout): class SaplFormLayout(Layout):
def __init__(self, *fields): def __init__(self, *fields):
buttons = FormActions( buttons = form_actions(
Submit('save', _('Enviar'), css_class='btn btn-primary '),
HTML('<a href="{{ view.cancel_url }}"' HTML('<a href="{{ view.cancel_url }}"'
' class="btn btn-inverse">%s</a>' % _('Cancelar'))) ' class="btn btn-inverse">%s</a>' % _('Cancelar')))
_fields = list(to_fieldsets(fields)) + [to_row([(buttons, 12)])] _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 re import sub
from crispy_forms.helper import FormHelper 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 import forms
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
@ -15,6 +15,7 @@ from django.views.generic.edit import FormMixin
from rest_framework import generics from rest_framework import generics
import sapl import sapl
from sapl.layout import form_actions
from materia.models import (Autoria, DocumentoAcessorio, from materia.models import (Autoria, DocumentoAcessorio,
TipoMateriaLegislativa, Tramitacao) TipoMateriaLegislativa, Tramitacao)
from norma.models import NormaJuridica from norma.models import NormaJuridica
@ -2410,10 +2411,7 @@ class SessaoForm(ModelForm):
row3, row3,
row4, row4,
row5, row5,
ButtonHolder( form_actions()
Submit('submit', 'Salvar',
css_class='button primary')
)
) )
) )
super(SessaoForm, self).__init__(*args, **kwargs) super(SessaoForm, self).__init__(*args, **kwargs)
@ -2505,12 +2503,7 @@ class AcompanharMateriaForm(ModelForm):
row1 = sapl.layout.to_row([('email', 10)]) row1 = sapl.layout.to_row([('email', 10)])
row1.append( row1.append(
Column( Column(form_actions(save_label='Cadastrar'), css_class='columns-large-2')
ButtonHolder(
Submit('Submit', 'Cadastrar',
css_class='button primary')
), css_class='columns-large-2'
)
) )
self.helper = FormHelper() self.helper = FormHelper()

Loading…
Cancel
Save