From 7f582bedbbe9c3df503cce83c3a5c48caaf78750 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Wed, 9 Nov 2016 15:00:47 -0200 Subject: [PATCH] Conserta template do resultado da pesquisa de norma --- sapl/norma/forms.py | 6 ++- sapl/norma/urls.py | 2 +- sapl/norma/views.py | 1 + sapl/templates/navbar.yaml | 2 +- .../templates/norma/normajuridica_filter.html | 54 ++++++++++++------- 5 files changed, 41 insertions(+), 24 deletions(-) diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index acfaaad42..3e9abec99 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -50,7 +50,7 @@ class NormaFilterSet(django_filters.FilterSet): class Meta: model = NormaJuridica fields = ['tipo', 'numero', 'ano', 'data', - 'data_publicacao', 'ementa'] + 'data_publicacao', 'ementa', 'assuntos'] def __init__(self, *args, **kwargs): super(NormaFilterSet, self).__init__(*args, **kwargs) @@ -59,12 +59,14 @@ class NormaFilterSet(django_filters.FilterSet): row2 = to_row([('numero', 6), ('ano', 6)]) row3 = to_row([('ementa', 12)]) row4 = to_row([('data', 6), ('data_publicacao', 6)]) + row5 = to_row([('assuntos', 12)]) + self.form.helper = FormHelper() self.form.helper.form_method = 'GET' self.form.helper.layout = Layout( Fieldset(_('Pesquisa de Norma'), - row1, row2, row3, row4, + row1, row2, row3, row4, row5, form_actions(save_label='Pesquisar')) ) diff --git a/sapl/norma/urls.py b/sapl/norma/urls.py index 615eae0ce..8c261e23e 100644 --- a/sapl/norma/urls.py +++ b/sapl/norma/urls.py @@ -18,5 +18,5 @@ urlpatterns = [ url(r'^sistema/norma/assunto/', include(AssuntoNormaCrud.get_urls())), url(r'^norma/pesquisar$', - NormaPesquisaView.as_view(), name='pesquisar_norma'), + NormaPesquisaView.as_view(), name='norma_pesquisa'), ] diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 78636f792..5a0dc283a 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -36,6 +36,7 @@ class NormaPesquisaView(FilterView): context['title'] = _('Pesquisar Norma Jurídica') qr = self.request.GET.copy() + if 'page' in qr: del qr['page'] diff --git a/sapl/templates/navbar.yaml b/sapl/templates/navbar.yaml index d0e9f1082..9b3ee0a52 100644 --- a/sapl/templates/navbar.yaml +++ b/sapl/templates/navbar.yaml @@ -45,7 +45,7 @@ - title: {% trans 'Normas Jurídicas' %} children: - title: {% trans 'Pesquisar Normas Jurídicas' %} - url: sapl.norma:pesquisar_norma + url: sapl.norma:norma_pesquisa - title: {% trans 'Sistema' %} check_permission: base.menu_sistemas diff --git a/sapl/templates/norma/normajuridica_filter.html b/sapl/templates/norma/normajuridica_filter.html index a5cc486ad..9ae8e5294 100644 --- a/sapl/templates/norma/normajuridica_filter.html +++ b/sapl/templates/norma/normajuridica_filter.html @@ -7,12 +7,13 @@ {% if perms.norma.add_normajuridica %} {% blocktrans with verbose_name=view.verbose_name %} Adicionar Norma Jurídica {% endblocktrans %} - {% endif %} + {% endif %} {% if filter_url %} - {% trans 'Fazer nova pesquisa' %} + {% trans 'Fazer nova pesquisa' %} {% endif %} +

{% endblock %} {% block detail_content %} @@ -21,24 +22,37 @@ {% endif %} {% if filter_url %} - - - - - {% if paginator.count %} - {% if paginator.count > 1 %} -

{% blocktrans with paginator.count as total_normas %}Pesquisa concluída com sucesso! Foram encontradas {{total_normas}} normas.{% endblocktrans %}

- {% elif paginator.count == 1 %} -

{% trans 'Pesquisa concluída com sucesso! Foi encontrada 1 matéria.'%}

- {% endif %} - - {% for n in page_obj %} - - {% endfor %} - {% else %} - + {% if page_obj|length %} +
+ {% if page_obj|length > 1 %} +

Pesquisa concluída com sucesso! Foram encontradas {{paginator.count}} normas.

+ {% elif page_obj|length == 1 %} +

{% trans 'Pesquisa concluída com sucesso! Foi encontrada 1 norma.'%}

{% endif %} -

{% trans "Resultados" %}

{{n}}

Nenhuma norma encontrada com essas especificações

- {% include "paginacao.html" %} +
+ + + + + + + + + + + {% for n in page_obj %} + + + + + + + + {% endfor %} +
TipoNúmeroAnoDataEmenta
{{n.tipo}}{{n.numero}}{{n.ano}}{{n.data}}{{n.ementa|safe}}
+ {% else %} +

+

Nenhuma norma encontrada com essas especificações

+ {% endif %} {% endif %} {% endblock detail_content %}