Browse Source

Coloca como Placeholder 'De-Para' no Range de Datas de Apresentacao e Publicacao

pull/282/head
Eduardo Calil 9 years ago
parent
commit
7ae0c37e80
  1. 30
      materia/forms.py
  2. 2
      materia/views.py

30
materia/forms.py

@ -6,9 +6,7 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db import models from django.db import models
from django.db.models import Max from django.db.models import Max
from django.forms import ModelForm from django.forms import ModelForm
from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django_filters.utils import resolve_field
import crispy_layout_mixin import crispy_layout_mixin
import sapl import sapl
@ -22,7 +20,6 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria,
Numeracao, Proposicao, Relatoria, TipoMateriaLegislativa, Numeracao, Proposicao, Relatoria, TipoMateriaLegislativa,
Tramitacao) Tramitacao)
ANO_CHOICES = [('', '---------')] + RANGE_ANOS ANO_CHOICES = [('', '---------')] + RANGE_ANOS
@ -601,9 +598,11 @@ class RangeWidgetOverride(forms.MultiWidget):
def __init__(self, attrs=None): def __init__(self, attrs=None):
widgets = (forms.DateInput(format='%d/%m/%Y', widgets = (forms.DateInput(format='%d/%m/%Y',
attrs={'class': 'dateinput'}), attrs={'class': 'dateinput',
'placeholder': 'Inicial'}),
forms.DateInput(format='%d/%m/%Y', forms.DateInput(format='%d/%m/%Y',
attrs={'class': 'dateinput'})) attrs={'class': 'dateinput',
'placeholder': 'Final'}))
super(RangeWidgetOverride, self).__init__(widgets, attrs) super(RangeWidgetOverride, self).__init__(widgets, attrs)
def decompress(self, value): def decompress(self, value):
@ -621,7 +620,7 @@ class MateriaLegislativaFilterSet(django_filters.FilterSet):
'filter_class': django_filters.DateFromToRangeFilter, 'filter_class': django_filters.DateFromToRangeFilter,
'extra': lambda f: { 'extra': lambda f: {
'label': '%s (%s)' % (f.verbose_name, _('Inicial - Final')), 'label': '%s (%s)' % (f.verbose_name, _('Inicial - Final')),
'widget': RangeWidgetOverride}, 'widget': RangeWidgetOverride}
}} }}
ano = django_filters.ChoiceFilter(required=False, ano = django_filters.ChoiceFilter(required=False,
@ -688,10 +687,9 @@ class MateriaLegislativaFilterSet(django_filters.FilterSet):
('ano', 4), ('ano', 4),
('numero_protocolo', 4)]) ('numero_protocolo', 4)])
row3 = crispy_layout_mixin.to_row( row3 = crispy_layout_mixin.to_row(
[('data_apresentacao', 6)]) [('data_apresentacao', 6),
('data_publicacao', 6)])
row4 = crispy_layout_mixin.to_row( row4 = crispy_layout_mixin.to_row(
[('data_publicacao', 6)])
row5 = crispy_layout_mixin.to_row(
[('autoria__autor', 0), [('autoria__autor', 0),
(Button('pesquisar', (Button('pesquisar',
'Pesquisar Autor', 'Pesquisar Autor',
@ -699,29 +697,29 @@ class MateriaLegislativaFilterSet(django_filters.FilterSet):
(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( row5 = crispy_layout_mixin.to_row(
[('autoria__autor__tipo', 6), [('autoria__autor__tipo', 6),
('autoria__partido', 6)]) ('autoria__partido', 6)])
row7 = crispy_layout_mixin.to_row( row6 = crispy_layout_mixin.to_row(
[('relatoria__parlamentar_id', 6), [('relatoria__parlamentar_id', 6),
('local_origem_externa', 6)]) ('local_origem_externa', 6)])
row8 = crispy_layout_mixin.to_row( row7 = crispy_layout_mixin.to_row(
[('tramitacao__unidade_tramitacao_destino', 6), [('tramitacao__unidade_tramitacao_destino', 6),
('tramitacao__status', 6)]) ('tramitacao__status', 6)])
row9 = crispy_layout_mixin.to_row( row8 = crispy_layout_mixin.to_row(
[('em_tramitacao', 6), [('em_tramitacao', 6),
('o', 6)]) ('o', 6)])
row10 = crispy_layout_mixin.to_row( row9 = crispy_layout_mixin.to_row(
[('ementa', 12)]) [('ementa', 12)])
self.form.helper = FormHelper() self.form.helper = FormHelper()
self.form.helper.form_method = 'GET' self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout( self.form.helper.layout = Layout(
Fieldset(_('Pesquisa Básica'), Fieldset(_('Pesquisa Básica'),
row1, row2, row3, row4, row1, row2, row3,
HTML(sapl.utils.autor_label), HTML(sapl.utils.autor_label),
HTML(sapl.utils.autor_modal), HTML(sapl.utils.autor_modal),
row5, row6, row7, row8, row9, row10, row4, row5, row6, row7, row8, row9,
form_actions(save_label='Pesquisar')) form_actions(save_label='Pesquisar'))
) )

2
materia/views.py

@ -1246,7 +1246,7 @@ class MateriaLegislativaPesquisaView(FilterView):
# Se a pesquisa estiver quebrando com a paginação # Se a pesquisa estiver quebrando com a paginação
# Olhe esta função abaixo # Olhe esta função abaixo
# Provavelmente você criou um novo campo no Form/Field # Provavelmente você criou um novo campo no Form/FilterSet
# Então a ordem da URL está diferente # Então a ordem da URL está diferente
data = self.filterset.data data = self.filterset.data
if (data and data.get('tipo') is not None): if (data and data.get('tipo') is not None):

Loading…
Cancel
Save