Browse Source

Fix #2456

até a release 1.6.1 do django-crispy-forms, os fields em Meta.Fields eram
    renderizados mesmo se não mencionados no helper.
    Com esta mudança (6b93e8a362)
    render_unmentioned_fields foi adicionado uma condição em que a cada
    instância do Helper, fosse decidido se os fields não mencionados serião ou
    não renderizados...
    O Sapl até este commit: 22b87f36eb
    utilizou o django-crispy-forms na versão 1.6.1, ou seja,
    sem a condição render_unmentioned_fields o que fazia o FormHelper, na 1.6.1
    set comportar como se, agora, na 1.7.2 o default fosse True.
    Como todos os Forms do Sapl foram construídos assumindo que fields
    não incluídos explicitamente no Helper, o helper o incluiria implicitamente,
    e assim o era, de acordo com commit acima do django-crispy-forms, então
    cria-se essa classe:

        class SaplFormHelper(FormHelper):
            render_unmentioned_fields = True

    onde torna o default, antes False, agora = True, o esperado pelos forms do sapl,
    e substituí-se todos os FormHelper por SaplFormHelper dentro do projeto Sapl

    esta explicação ficará aqui dentro do código, via commit, e na issue #2456.
pull/2495/head
Leandro Roberto 6 years ago
parent
commit
1b5fbd8457
  1. 4
      sapl/audiencia/forms.py
  2. 38
      sapl/base/forms.py
  3. 30
      sapl/compilacao/forms.py
  4. 57
      sapl/crispy_layout_mixin.py
  5. 4
      sapl/crud/base.py
  6. 38
      sapl/materia/forms.py
  7. 4
      sapl/materia/views.py
  8. 8
      sapl/norma/forms.py
  9. 4
      sapl/parlamentares/forms.py
  10. 24
      sapl/protocoloadm/forms.py
  11. 14
      sapl/sessao/forms.py
  12. 4
      sapl/utils.py

4
sapl/audiencia/forms.py

@ -7,7 +7,7 @@ from django.utils.translation import ugettext_lazy as _
from sapl.audiencia.models import AudienciaPublica, TipoAudienciaPublica, AnexoAudienciaPublica
from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout
from crispy_forms.helper import FormHelper
from sapl.crispy_layout_mixin import SaplFormHelper
from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row
from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa
from sapl.utils import timezone
@ -134,7 +134,7 @@ class AnexoAudienciaPublicaForm(forms.ModelForm):
row2 = to_row(
[('assunto', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(
Fieldset(_('Identificação Básica'),
row1, row2))

38
sapl/base/forms.py

@ -1,7 +1,7 @@
import logging
from crispy_forms.bootstrap import FieldWithButtons, InlineRadios, StrictButton
from crispy_forms.helper import FormHelper
from sapl.crispy_layout_mixin import SaplFormHelper
from crispy_forms.layout import HTML, Button, Div, Field, Fieldset, Layout, Row
from django import forms
from django.conf import settings
@ -114,7 +114,7 @@ class UsuarioCreateForm(ModelForm):
row4 = to_row([(form_actions(label='Confirmar'), 6)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
row0,
row1,
@ -154,7 +154,7 @@ class UsuarioEditForm(ModelForm):
row3 = to_row([(form_actions(label='Salvar Alterações'), 6)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
row1,
row2,
@ -432,7 +432,7 @@ class AutorForm(ModelForm):
controle_acesso = Fieldset(_('Controle de Acesso do Autor'),
*controle_acesso)
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(autor_select, controle_acesso)
super(AutorForm, self).__init__(*args, **kwargs)
@ -697,7 +697,7 @@ class RelatorioAtasFilterSet(django_filters.FilterSet):
row1 = to_row([('data_inicio', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Atas das Sessões Plenárias'),
@ -733,7 +733,7 @@ class RelatorioNormasMesFilterSet(django_filters.FilterSet):
row1 = to_row([('ano', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Normas por mês do ano.'),
@ -762,7 +762,7 @@ class EstatisticasAcessoNormasForm(Form):
row1 = to_row([('ano', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.form_method = 'GET'
self.helper.layout = Layout(
Fieldset(_('Normas por acessos nos meses do ano.'),
@ -800,7 +800,7 @@ class RelatorioNormasVigenciaFilterSet(django_filters.FilterSet):
row1 = to_row([('ano', 12)])
row2 = to_row([('vigencia', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Normas por vigência.'),
@ -828,7 +828,7 @@ class RelatorioPresencaSessaoFilterSet(django_filters.FilterSet):
row1 = to_row([('data_inicio', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Presença dos parlamentares nas sessões plenárias'),
@ -868,7 +868,7 @@ class RelatorioHistoricoTramitacaoFilterSet(django_filters.FilterSet):
('tramitacao__unidade_tramitacao_local', 4),
('tramitacao__status', 4)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Histórico de Tramitação'),
@ -901,7 +901,7 @@ class RelatorioDataFimPrazoTramitacaoFilterSet(django_filters.FilterSet):
('tramitacao__unidade_tramitacao_local', 4),
('tramitacao__status', 4)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Tramitações por fim de prazo'),
@ -932,7 +932,7 @@ class RelatorioReuniaoFilterSet(django_filters.FilterSet):
('nome', 4),
('tema', 4)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Reunião de Comissão'),
@ -962,7 +962,7 @@ class RelatorioAudienciaFilterSet(django_filters.FilterSet):
[('tipo', 4),
('nome', 4)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Audiência Pública'),
@ -1006,7 +1006,7 @@ class RelatorioMateriasTramitacaoilterSet(django_filters.FilterSet):
row3 = to_row([('tramitacao__unidade_tramitacao_destino', 12)])
row4 = to_row([('tramitacao__status', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisa de Matéria em Tramitação'),
@ -1032,7 +1032,7 @@ class RelatorioMateriasPorAnoAutorTipoFilterSet(django_filters.FilterSet):
row1 = to_row(
[('ano', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisar'),
@ -1074,7 +1074,7 @@ class RelatorioMateriasPorAutorFilterSet(django_filters.FilterSet):
'limpar Autor',
css_class='btn btn-primary btn-sm'), 10)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisar'),
@ -1196,7 +1196,7 @@ class RecuperarSenhaForm(PasswordResetForm):
def __init__(self, *args, **kwargs):
row1 = to_row(
[('email', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(_('Insira o e-mail cadastrado com a sua conta'),
row1,
@ -1233,7 +1233,7 @@ class NovaSenhaForm(SetPasswordForm):
[('new_password1', 6),
('new_password2', 6)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
row1,
form_actions(label='Enviar'))
@ -1266,7 +1266,7 @@ class AlterarSenhaForm(Form):
[('new_password1', 6),
('new_password2', 6)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
row1,
row2,

30
sapl/compilacao/forms.py

@ -3,7 +3,7 @@ from datetime import timedelta
from crispy_forms.bootstrap import (Alert, FieldWithButtons, FormActions,
InlineCheckboxes, InlineRadios,
StrictButton)
from crispy_forms.helper import FormHelper
from sapl.crispy_layout_mixin import SaplFormHelper
from crispy_forms.layout import (HTML, Button, Column, Div, Field, Fieldset,
Layout, Row, Submit)
from django import forms
@ -84,7 +84,7 @@ class TipoTaForm(ModelForm):
('perfis', 12),
])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(
Fieldset(_('Identificação Básica'),
row1, css_class="col-md-12"),
@ -153,7 +153,7 @@ class TaForm(ModelForm):
('participacao_social', 3),
])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(
Fieldset(_('Identificação Básica'), row1, css_class="col-md-12"),
Fieldset(
@ -268,7 +268,7 @@ class NotaForm(ModelForm):
css_class='form-group row justify-content-between mr-1 ml-1'
)
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Div(
@ -363,7 +363,7 @@ class VideForm(ModelForm):
'texto',
placeholder=_('Texto Adicional ao Vide')), 12)))))
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Div(
Div(HTML(_('Vides')), css_class='card-header bg-light'),
@ -471,7 +471,7 @@ class PublicacaoForm(ModelForm):
('url_externa', 8),
])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(
Fieldset(Publicacao._meta.verbose_name,
row1, row2, row3, css_class="col-md-12"))
@ -659,7 +659,7 @@ class DispositivoEdicaoBasicaForm(ModelForm):
for f in fields:
self.base_fields.update({f: getattr(self, f)})
self.helper = FormHelper()
self.helper = SaplFormHelper()
if not editor_type:
cancel_label = _('Ir para o Editor Sequencial')
@ -790,7 +790,7 @@ class DispositivoSearchModalForm(Form):
)
)
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
fields_search,
Row(to_column((Div(css_class='result-busca-dispositivo'), 12))))
@ -903,7 +903,7 @@ class DispositivoEdicaoVigenciaForm(ModelForm):
row_vigencia,
css_class="col-md-12"))
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(
*layout,
cancel_label=_('Ir para o Editor Sequencial'))
@ -1023,7 +1023,7 @@ class DispositivoDefinidorVigenciaForm(Form):
row_vigencia,
css_class="col-md-12"))
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(
*layout,
cancel_label=_('Ir para o Editor Sequencial'))
@ -1162,7 +1162,7 @@ class DispositivoEdicaoAlteracaoForm(ModelForm):
if hasattr(self, f):
self.base_fields.update({f: getattr(self, f)})
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(
*layout,
cancel_label=_('Ir para o Editor Sequencial'))
@ -1328,7 +1328,7 @@ class TextNotificacoesForm(Form):
(Submit('submit-form', _('Filtrar'),
css_class='btn btn-primary float-right'), 2)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(field_type_notificacoes)
super(TextNotificacoesForm, self).__init__(*args, **kwargs)
@ -1374,7 +1374,7 @@ class DispositivoRegistroAlteracaoForm(Form):
_fields = [Div(*layout, css_class="row")] + \
[to_row([(buttons, 12)])]
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(*_fields)
super(DispositivoRegistroAlteracaoForm, self).__init__(*args, **kwargs)
@ -1431,7 +1431,7 @@ class DispositivoRegistroRevogacaoForm(Form):
_fields = [Div(*layout, css_class="row")] + \
[to_row([(buttons, 12)])]
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(*_fields)
super(DispositivoRegistroRevogacaoForm, self).__init__(*args, **kwargs)
@ -1481,7 +1481,7 @@ class DispositivoRegistroInclusaoForm(Form):
_fields = [Div(*layout, css_class="row")] + \
[to_row([(buttons, 12)])]
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(*_fields)
super(DispositivoRegistroInclusaoForm, self).__init__(*args, **kwargs)

57
sapl/crispy_layout_mixin.py

@ -52,6 +52,35 @@ def form_actions(more=[Div(css_class='clearfix')],
)
class SaplFormHelper(FormHelper):
render_unmentioned_fields = True # default = False
"""
até a release 1.6.1 do django-crispy-forms, os fields em Meta.Fields eram
renderizados mesmo se não mencionados no helper.
Com esta mudança (https://github.com/django-crispy-forms/django-crispy-forms/commit/6b93e8a362422db8fe54aa731319c7cbc39990ba)
render_unmentioned_fields foi adicionado uma condição em que a cada
instância do Helper, fosse decidido se os fields não mencionados serião ou
não renderizados...
O Sapl até este commit: https://github.com/interlegis/sapl/commit/22b87f36ebc8659a6ecaf8831ab0f425206b0993
utilizou o django-crispy-forms na versão 1.6.1, ou seja,
sem a condição render_unmentioned_fields o que fazia o FormHelper, na 1.6.1
set comportar como se, agora, na 1.7.2 o default fosse True.
Como todos os Forms do Sapl foram construídos assumindo que fields
não incluídos explicitamente no Helper, o helper o incluiria implicitamente,
e assim o era, de acordo com commit acima do django-crispy-forms, então
cria-se essa classe:
class SaplFormHelper(FormHelper):
render_unmentioned_fields = True
onde torna o default, antes False, agora = True, o esperado pelos forms do sapl,
e substituí-se todos os FormHelper por SaplFormHelper dentro do projeto Sapl
esta explicação ficará aqui dentro do código, via commit, e na issue #2456.
"""
class SaplFormLayout(Layout):
def __init__(self, *fields, cancel_label=_('Cancelar'),
@ -188,10 +217,34 @@ class CrispyLayoutFormMixin:
pass
else:
if self.layout_key:
form.helper = FormHelper()
form.helper.layout = SaplFormLayout(*self.get_layout())
form.helper = SaplFormHelper()
layout = self.get_layout()
"""if hasattr(form, '_meta') and \
hasattr(form._meta, 'fields') and \
form._meta.fields is not None:
self.validate_layout(form, layout)"""
form.helper.layout = SaplFormLayout(*layout)
return form
"""def validate_layout(self, form, layout):
fields = set()
for fieldset in layout:
for el in fieldset:
if isinstance(el, str):
continue
for field, size in el:
fields.add(field)
intersection = set(form._meta.fields) - fields
if intersection:
raise Exception(_('Os campos {} não aparecem na definição de layout'
' da interface do usuário').format(intersection))
"""
@property
def list_field_names(self):
'''The list of field names to display on table

4
sapl/crud/base.py

@ -2,7 +2,7 @@ import logging
from braces.views import FormMessagesMixin
from crispy_forms.bootstrap import FieldWithButtons, StrictButton
from crispy_forms.helper import FormHelper
from sapl.crispy_layout_mixin import SaplFormHelper
from crispy_forms.layout import Field, Layout
from django import forms
from django.conf.urls import url
@ -150,7 +150,7 @@ class ListWithSearchForm(forms.Form):
def __init__(self, *args, **kwargs):
super(ListWithSearchForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.form_class = 'form-inline'
self.helper.form_method = 'GET'
self.helper.layout = Layout(

38
sapl/materia/forms.py

@ -3,7 +3,7 @@ import logging
import os
from crispy_forms.bootstrap import Alert, InlineRadios
from crispy_forms.helper import FormHelper
from sapl.crispy_layout_mixin import SaplFormHelper
from crispy_forms.layout import (HTML, Button, Column, Div, Field, Fieldset,
Layout, Row)
from django import forms
@ -76,7 +76,7 @@ class AdicionarVariasAutoriasFilterSet(django_filters.FilterSet):
row1 = to_row([('nome', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Filtrar Autores'),
@ -112,7 +112,7 @@ class ReceberProposicaoForm(Form):
def __init__(self, *args, **kwargs):
row1 = to_row([('cod_hash', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(
_('Incorporar Proposição'), row1,
@ -145,7 +145,7 @@ class MateriaSimplificadaForm(ModelForm):
row4 = to_row([('ementa', 12)])
row5 = to_row([('texto_original', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(
_('Formulário Simplificado'),
@ -346,7 +346,7 @@ class AcompanhamentoMateriaForm(ModelForm):
Column(form_actions(label='Cadastrar'), css_class='col-md-2')
)
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(
_('Acompanhamento de Matéria por e-mail'), row1
@ -896,7 +896,7 @@ class MateriaLegislativaFilterSet(django_filters.FilterSet):
('tipo_listagem', 4)
])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisa Básica'),
@ -1016,7 +1016,7 @@ class AutoriaForm(ModelForm):
('autor', 4),
('primeiro_autor', 4)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(_('Autoria'),
row1, 'data_relativa', form_actions(label='Salvar')))
@ -1077,7 +1077,7 @@ class AutoriaMultiCreateForm(Form):
row2 = to_row([('autor', 12), ])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(
_('Autorias'), row1, row2, 'data_relativa', 'autores',
@ -1117,7 +1117,7 @@ class AcessorioEmLoteFilterSet(django_filters.FilterSet):
row1 = to_row([('tipo', 12)])
row2 = to_row([('data_apresentacao', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Documentos Acessórios em Lote'),
@ -1142,7 +1142,7 @@ class PrimeiraTramitacaoEmLoteFilterSet(django_filters.FilterSet):
row1 = to_row([('tipo', 12)])
row2 = to_row([('data_apresentacao', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Primeira Tramitação'),
@ -1177,7 +1177,7 @@ class TramitacaoEmLoteFilterSet(django_filters.FilterSet):
('tramitacao__status', 4)])
row2 = to_row([('data_apresentacao', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Tramitação em Lote'),
@ -1241,7 +1241,7 @@ class TipoProposicaoForm(ModelForm):
)
)
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(tipo_select)
super(TipoProposicaoForm, self).__init__(*args, **kwargs)
@ -1431,7 +1431,7 @@ class ProposicaoForm(forms.ModelForm):
('ano_materia', 6)]),
), 12)),
)
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(*fields)
super(ProposicaoForm, self).__init__(*args, **kwargs)
@ -1579,7 +1579,7 @@ class DevolverProposicaoForm(forms.ModelForm):
)
)
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(*fields)
def clean(self):
@ -1762,7 +1762,7 @@ class ConfirmarProposicaoForm(ProposicaoForm):
fields.append(
Fieldset(_('Registro de Incorporação'), Row(*itens_incorporacao)))
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(*fields)
self.fields['tipo_readonly'].initial = self.instance.tipo.descricao
@ -2118,7 +2118,7 @@ class EtiquetaPesquisaForm(forms.Form):
[('processo_inicial', 6),
('processo_final', 6)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(
('Formulário de Etiqueta'),
@ -2203,7 +2203,7 @@ class FichaPesquisaForm(forms.Form):
('data_inicial', 3),
('data_final', 3)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(
('Formulário de Ficha'),
@ -2244,7 +2244,7 @@ class FichaSelecionaForm(forms.Form):
row1 = to_row(
[('materia', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(
('Selecione a ficha que deseja imprimir'),
@ -2314,7 +2314,7 @@ class ExcluirTramitacaoEmLote(forms.Form):
[('unidade_tramitacao_local', 6),
('unidade_tramitacao_destino', 6)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(_('Dados das Tramitações'),
row1,

4
sapl/materia/views.py

@ -3,7 +3,7 @@ import logging
from random import choice
from string import ascii_letters, digits
from crispy_forms.helper import FormHelper
from sapl.crispy_layout_mixin import SaplFormHelper
from crispy_forms.layout import HTML
from django.conf import settings
from django.contrib import messages
@ -1350,7 +1350,7 @@ class TramitacaoCrud(MasterDetailCrud):
def montar_helper_documento_acessorio(self):
autor_row = montar_row_autor('autor')
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(*self.get_layout())
# Adiciona o novo campo 'autor' e mecanismo de busca

8
sapl/norma/forms.py

@ -1,7 +1,7 @@
import logging
from crispy_forms.helper import FormHelper
from sapl.crispy_layout_mixin import SaplFormHelper
from crispy_forms.layout import Fieldset, Layout
from django import forms
from django.core.exceptions import ObjectDoesNotExist, ValidationError
@ -71,7 +71,7 @@ class NormaFilterSet(django_filters.FilterSet):
row4 = to_row([('data_vigencia', 12)])
row5 = to_row([('o', 6), ('indexacao', 6)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisa de Norma'),
@ -238,7 +238,7 @@ class AutoriaNormaForm(ModelForm):
('autor', 4),
('primeiro_autor', 4)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(_('Autoria'),
row1, 'data_relativa', form_actions(label='Salvar')))
@ -400,7 +400,7 @@ class NormaPesquisaSimplesForm(forms.Form):
row2 = to_row(
[('titulo', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(
('Índice de Normas'),

4
sapl/parlamentares/forms.py

@ -1,7 +1,7 @@
from datetime import timedelta
import logging
from crispy_forms.helper import FormHelper
from sapl.crispy_layout_mixin import SaplFormHelper
from crispy_forms.layout import Fieldset, Layout
from django import forms
from django.contrib.auth import get_user_model
@ -446,7 +446,7 @@ class VotanteForm(ModelForm):
def __init__(self, *args, **kwargs):
row1 = to_row([('username', 4)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(_('Votante'),
row1, form_actions(label='Salvar'))

24
sapl/protocoloadm/forms.py

@ -2,7 +2,7 @@
import logging
from crispy_forms.bootstrap import InlineRadios, Alert
from crispy_forms.helper import FormHelper
from sapl.crispy_layout_mixin import SaplFormHelper
from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout, Div
from django import forms
from django.core.exceptions import (MultipleObjectsReturned,
@ -57,7 +57,7 @@ class AcompanhamentoDocumentoForm(ModelForm):
Column(form_actions(label='Cadastrar'), css_class='col-md-2')
)
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(
_('Acompanhamento de Documento por e-mail'), row1
@ -136,7 +136,7 @@ class ProtocoloFilterSet(django_filters.FilterSet):
row5 = to_row(
[('tipo_processo', 6), ('o', 6)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisar Protocolo'),
@ -212,7 +212,7 @@ class DocumentoAdministrativoFilterSet(django_filters.FilterSet):
('tramitacaoadministrativo__unidade_tramitacao_destino', 5),
])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisar Documento'),
@ -305,7 +305,7 @@ class AnularProcoloAdmForm(ModelForm):
row2 = to_row(
[('justificativa_anulacao', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(_('Identificação do Protocolo'),
row1,
@ -404,7 +404,7 @@ class ProtocoloDocumentForm(ModelForm):
row7 = to_row(
[('numero', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(_('Identificação de Documento'),
row1,
@ -583,7 +583,7 @@ class ProtocoloMateriaForm(ModelForm):
row6 = to_row(
[('numero', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(_('Identificação da Matéria'),
row1,
@ -910,7 +910,7 @@ class DocumentoAdministrativoForm(ModelForm):
row7 = to_row(
[('observacao', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(
Fieldset(_('Identificação Básica'),
row1, row2, row3, row4, row5),
@ -978,7 +978,7 @@ class DesvincularDocumentoForm(ModelForm):
('ano', 4),
('tipo', 4)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(_('Identificação do Documento'),
row1,
@ -1043,7 +1043,7 @@ class DesvincularMateriaForm(forms.Form):
('ano', 4),
('tipo', 4)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(_('Identificação da Matéria'),
row1,
@ -1111,7 +1111,7 @@ class FichaPesquisaAdmForm(forms.Form):
('data_inicial', 3),
('data_final', 3)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(
('Formulário de Ficha'),
@ -1152,7 +1152,7 @@ class FichaSelecionaAdmForm(forms.Form):
row1 = to_row(
[('documento', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(
('Selecione a ficha que deseja imprimir'),

14
sapl/sessao/forms.py

@ -1,6 +1,6 @@
from datetime import datetime
from crispy_forms.helper import FormHelper
from sapl.crispy_layout_mixin import SaplFormHelper
from crispy_forms.layout import HTML, Button, Fieldset, Layout
from django import forms
from django.contrib.contenttypes.models import ContentType
@ -207,7 +207,7 @@ class RetiradaPautaForm(ModelForm):
('expediente', 6)])
row3 = to_row([('observacao', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(
Fieldset(_('Retirada de Pauta'),
row1, row2, row3))
@ -591,7 +591,7 @@ class SessaoPlenariaFilterSet(django_filters.FilterSet):
('data_inicio__day', 3),
('tipo', 3)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(self.titulo,
@ -664,7 +664,7 @@ class AdicionarVariasMateriasFilterSet(MateriaLegislativaFilterSet):
row9 = to_row(
[('ementa', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisa de Matéria'),
@ -787,7 +787,7 @@ class ResumoOrdenacaoForm(forms.Form):
row11 = to_row(
[('decimo_primeiro', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = Layout(
Fieldset(_(''),
row1, row2, row3, row4, row5,
@ -853,7 +853,7 @@ class JustificativaAusenciaForm(ModelForm):
row8 = to_row(
[('observacao', 12)])
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(
Fieldset(_('Justificativa de Ausência'),
row1, row2, row3,
@ -981,7 +981,7 @@ class VotacaoEmBlocoFilterSet(MateriaLegislativaFilterSet):
row9 = to_row(
[('ementa', 12)])
self.form.helper = FormHelper()
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisa de Matéria'),

4
sapl/utils.py

@ -6,7 +6,7 @@ import re
from unicodedata import normalize as unicodedata_normalize
import unicodedata
from crispy_forms.helper import FormHelper
from sapl.crispy_layout_mixin import SaplFormHelper
from crispy_forms.layout import HTML, Button
from django import forms
from django.apps import apps
@ -111,7 +111,7 @@ def montar_row_autor(name):
def montar_helper_autor(self):
autor_row = montar_row_autor('nome')
self.helper = FormHelper()
self.helper = SaplFormHelper()
self.helper.layout = SaplFormLayout(*self.get_layout())
# Adiciona o novo campo 'autor' e mecanismo de busca

Loading…
Cancel
Save