Browse Source

Fixes #3497 (#3547)

pull/3556/head
Gustavo274 3 years ago
committed by GitHub
parent
commit
967403a8a4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      sapl/norma/forms.py
  2. 11
      sapl/templates/norma/normajuridica_filter.html

33
sapl/norma/forms.py

@ -1,6 +1,6 @@
import logging import logging
from crispy_forms.layout import Fieldset, Layout, HTML from crispy_forms.layout import (Button, Fieldset, HTML, Layout)
from django import forms from django import forms
from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db import models from django.db import models
@ -15,7 +15,8 @@ from sapl.crispy_layout_mixin import form_actions, SaplFormHelper, to_row
from sapl.materia.forms import choice_anos_com_materias from sapl.materia.forms import choice_anos_com_materias
from sapl.materia.models import (MateriaLegislativa, from sapl.materia.models import (MateriaLegislativa,
TipoMateriaLegislativa, Orgao) TipoMateriaLegislativa, Orgao)
from sapl.utils import (ANO_CHOICES, choice_anos_com_normas, from sapl.parlamentares.models import Partido
from sapl.utils import (autor_label, autor_modal, ANO_CHOICES, choice_anos_com_normas,
FileFieldCheckMixin, FilterOverridesMetaMixin, FileFieldCheckMixin, FilterOverridesMetaMixin,
NormaPesquisaOrderingFilter, RangeWidgetOverride, NormaPesquisaOrderingFilter, RangeWidgetOverride,
validar_arquivo) validar_arquivo)
@ -80,8 +81,13 @@ class NormaFilterSet(django_filters.FilterSet):
assuntos = django_filters.ModelChoiceFilter( assuntos = django_filters.ModelChoiceFilter(
queryset=AssuntoNorma.objects.all()) queryset=AssuntoNorma.objects.all())
autorianorma__autor = django_filters.CharFilter(method='filter_autoria') autorianorma__autor = django_filters.CharFilter(widget=forms.HiddenInput())
autorianorma__primeiro_autor = django_filters.CharFilter(method='filter_autoria') autorianorma__primeiro_autor = django_filters.BooleanFilter(
required=False,
label=_('Primeiro Autor'))
autorianorma__autor__parlamentar_set__filiacao__partido = django_filters.ModelChoiceFilter(
queryset=Partido.objects.all(),
label=_('Normas por Partido'))
o = NormaPesquisaOrderingFilter(help_text='') o = NormaPesquisaOrderingFilter(help_text='')
@ -89,22 +95,39 @@ class NormaFilterSet(django_filters.FilterSet):
model = NormaJuridica model = NormaJuridica
fields = ['orgao', 'tipo', 'numero', 'ano', 'data', fields = ['orgao', 'tipo', 'numero', 'ano', 'data',
'data_vigencia', 'data_publicacao', 'ementa', 'assuntos', 'data_vigencia', 'data_publicacao', 'ementa', 'assuntos',
'autorianorma__autor', 'autorianorma__primeiro_autor'] 'autorianorma__autor', 'autorianorma__primeiro_autor', 'autorianorma__autor__tipo']
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(NormaFilterSet, self).__init__(*args, **kwargs) super(NormaFilterSet, self).__init__(*args, **kwargs)
self.filters['autorianorma__autor__tipo'].label = _('Tipo de Autor')
row1 = to_row([('tipo', 4), ('numero', 4), ('ano', 4)]) row1 = to_row([('tipo', 4), ('numero', 4), ('ano', 4)])
row2 = to_row([('data', 6), ('data_publicacao', 6)]) row2 = to_row([('data', 6), ('data_publicacao', 6)])
row3 = to_row([('ementa', 6), ('assuntos', 6)]) row3 = to_row([('ementa', 6), ('assuntos', 6)])
row4 = to_row([('data_vigencia', 6), ('orgao', 6), ]) row4 = to_row([('data_vigencia', 6), ('orgao', 6), ])
row5 = to_row([('o', 6), ('indexacao', 6)]) row5 = to_row([('o', 6), ('indexacao', 6)])
row6 = to_row([
('autorianorma__autor', 0),
(Button('pesquisar',
'Pesquisar Autor',
css_class='btn btn-primary btn-sm'), 2),
(Button('limpar',
'Limpar Autor',
css_class='btn btn-primary btn-sm'), 2),
('autorianorma__primeiro_autor', 2),
('autorianorma__autor__tipo', 3),
('autorianorma__autor__parlamentar_set__filiacao__partido', 3)
])
self.form.helper = SaplFormHelper() self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET' self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout( self.form.helper.layout = Layout(
Fieldset(_('Pesquisa de Norma'), Fieldset(_('Pesquisa de Norma'),
row1, row2, row3, row4, row5, row1, row2, row3, row4, row5,
Fieldset(_('Pesquisa Avançada'),
row6,
HTML(autor_label),
HTML(autor_modal)),
form_actions(label='Pesquisar')) form_actions(label='Pesquisar'))
) )

11
sapl/templates/norma/normajuridica_filter.html

@ -79,6 +79,17 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</td> </td>
{% if n.autoria_set.all %}
<strong>Autor:</strong>
{% for a in n.autoria_set.all %}
{% if not forloop.first %}
</br> {{a.autor}}
{% else %}
&nbsp;{{a.autor}}
{% endif %}
{% endfor %}
</br>
{% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

Loading…
Cancel
Save