Browse Source

Constroi da pesquisa de materia com CrispyForms

pull/282/head
Eduardo Calil 9 years ago
parent
commit
0e4e0e666c
  1. 97
      materia/forms.py
  2. 5
      templates/materia/materialegislativa_filter.html

97
materia/forms.py

@ -583,7 +583,7 @@ class RangeWidgetOverride(forms.MultiWidget):
return [None, None] return [None, None]
def format_output(self, rendered_widgets): def format_output(self, rendered_widgets):
return '-'.join(rendered_widgets) return ''.join(rendered_widgets)
class MateriaLegislativaPesquisaFields(FilterSet): class MateriaLegislativaPesquisaFields(FilterSet):
@ -618,13 +618,8 @@ class MateriaLegislativaPesquisaFields(FilterSet):
help_text="", help_text="",
widget=RangeWidgetOverride) widget=RangeWidgetOverride)
autoria__autor = django_filters.ModelChoiceFilter( autoria__autor = django_filters.CharFilter(
label='Autor', widget=forms.HiddenInput(), required=False)
required=False,
queryset=Autor.objects.all().order_by('tipo'),
empty_label='Selecione',
help_text=""
)
autoria__autor__tipo = django_filters.ModelChoiceFilter( autoria__autor__tipo = django_filters.ModelChoiceFilter(
label=_('Tipo Autor'), label=_('Tipo Autor'),
@ -696,54 +691,56 @@ class MateriaLegislativaPesquisaFields(FilterSet):
'em_tramitacao', 'em_tramitacao',
'ementa', 'ementa',
'autoria__autor__id', 'autoria__autor__id',
'relatoria__parlamentar__id', 'relatoria__parlamentar_id',
'tramitacao__unidade_tramitacao_destino', 'tramitacao__unidade_tramitacao_destino',
'tramitacao__status', 'tramitacao__status',
'autoria__autor__tipo', 'autoria__autor__tipo',
'autoria__partido', 'autoria__partido',
'local_origem_externa'} 'local_origem_externa'}
# def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(MateriaLegislativaPesquisaFields, self).__init__(*args, **kwargs)
# row1 = crispy_layout_mixin.to_row(
# [('tipo', 12)]) row1 = crispy_layout_mixin.to_row(
# row2 = crispy_layout_mixin.to_row( [('tipo', 12)])
# [('numero', 4), row2 = crispy_layout_mixin.to_row(
# ('ano', 4), [('numero', 4),
# ('numero_protocolo', 4)]) ('ano', 4),
# row3 = crispy_layout_mixin.to_row( ('numero_protocolo', 4)])
# [('data_apresentacao', 6), row3 = crispy_layout_mixin.to_row(
# ('data_publicacao', 6)]) [('data_apresentacao', 6)])
# row4 = crispy_layout_mixin.to_row( row4 = crispy_layout_mixin.to_row(
# [('em_tramitacao', 6), [('data_publicacao', 6)])
# ('ementa', 6)]) row5 = crispy_layout_mixin.to_row(
# row5 = crispy_layout_mixin.to_row( [('autoria__autor', 0),
# [('autoria__autor__id', 0), (Button('pesquisar',
# (Button('pesquisar', 'Pesquisar Autor',
# 'Pesquisar Autor', css_class='btn btn-primary btn-sm'), 2),
# css_class='btn btn-primary btn-sm'), 2), (Button('limpar',
# (Button('limpar', 'limpar Autor',
# 'limpar Autor', css_class='btn btn-primary btn-sm'), 10)])
# css_class='btn btn-primary btn-sm'), 10)]) row6 = crispy_layout_mixin.to_row(
# row6 = crispy_layout_mixin.to_row( [('autoria__autor__tipo', 6),
# [('relatoria__parlamentar__id', 6), ('autoria__partido', 6)])
# ('tramitacao__unidade_tramitacao_destino', 6)]) row7 = crispy_layout_mixin.to_row(
# row7 = crispy_layout_mixin.to_row( [('relatoria__parlamentar_id', 6),
# [('tramitacao__status', 6), ('local_origem_externa', 6)])
# ('autoria__autor__tipo', 6)]) row8 = crispy_layout_mixin.to_row(
# row8 = crispy_layout_mixin.to_row( [('tramitacao__unidade_tramitacao_destino', 6),
# [('autoria__partido', 6), ('tramitacao__status', 6)])
# ('local_origem_externa', 6)]) row9 = crispy_layout_mixin.to_row(
[('em_tramitacao', 6),
# self.helper = FormHelper() ('ementa', 6)])
# self.helper.layout = Layout(
# Fieldset(_('Pesquisa Básica'), self.form.helper = FormHelper()
# row1, row2, row3, row4, self.form.helper.layout = Layout(
# HTML(sapl.utils.autor_label), Fieldset(_('Pesquisa Básica'),
# HTML(sapl.utils.autor_modal), row1, row2, row3, row4,
# row5, row6, row7, row8, HTML(sapl.utils.autor_label),
# form_actions(save_label='Pesquisar')) HTML(sapl.utils.autor_modal),
# ) row5, row6, row7, row8, row9,
form_actions(save_label='Pesquisar'))
)
def pega_ultima_tramitacao(): def pega_ultima_tramitacao():

5
templates/materia/materialegislativa_filter.html

@ -8,10 +8,7 @@
{% block detail_content %} {% block detail_content %}
<h1><b>Pesquisar Matéria</b></h1> <h1><b>Pesquisar Matéria</b></h1>
<br></br> <br></br>
<form action="" method="get"> {% crispy filter.form %}
{{ filter.form.as_p }}
<input type="submit" value="Pesquisar" />
</form>
<p></p> <p></p>
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
<thead class="thead-default"> <thead class="thead-default">

Loading…
Cancel
Save