diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index c01688611..0ba92b737 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -49,6 +49,9 @@ class NormaFilterSet(django_filters.FilterSet): method='filter_ementa', label=_('Pesquisar expressões na ementa da norma')) + apelido = django_filters.CharFilter(lookup_expr='icontains', + label=_('Apelido')) + indexacao = django_filters.CharFilter(lookup_expr='icontains', label=_('Indexação')) @@ -60,16 +63,16 @@ class NormaFilterSet(django_filters.FilterSet): class Meta(FilterOverridesMetaMixin): model = NormaJuridica fields = ['tipo', 'numero', 'ano', 'data', 'data_vigencia', - 'data_publicacao', 'ementa', 'assuntos'] + 'data_publicacao', 'ementa', 'assuntos', 'apelido'] def __init__(self, *args, **kwargs): super(NormaFilterSet, self).__init__(*args, **kwargs) row1 = to_row([('tipo', 4), ('numero', 4), ('ano', 4)]) - row2 = to_row([('data', 6), ('data_publicacao', 6)]) - row3 = to_row([('ementa', 6), ('assuntos', 6)]) + row2 = to_row([('ementa', 6), ('assuntos', 6)]) + row3 = to_row([('data', 6), ('data_publicacao', 6)]) row4 = to_row([('data_vigencia', 12)]) - row5 = to_row([('o', 6), ('indexacao', 6)]) + row5 = to_row([('o', 4), ('indexacao', 4), ('apelido', 4)]) self.form.helper = SaplFormHelper() self.form.helper.form_method = 'GET' @@ -132,7 +135,9 @@ class NormaJuridicaForm(FileFieldCheckMixin, ModelForm): 'indexacao', 'observacao', 'texto_integral', - 'assuntos'] + 'assuntos', + 'norma_de_destaque', + 'apelido'] widgets = {'assuntos': widgets.CheckboxSelectMultiple} def clean(self): diff --git a/sapl/norma/migrations/0025_auto_20190704_0816.py b/sapl/norma/migrations/0025_auto_20190704_0816.py new file mode 100644 index 000000000..f34623663 --- /dev/null +++ b/sapl/norma/migrations/0025_auto_20190704_0816.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.22 on 2019-07-04 11:16 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0024_auto_20190425_0917'), + ] + + operations = [ + migrations.AddField( + model_name='normajuridica', + name='apelido', + field=models.TextField(blank=True, verbose_name='Apelido'), + ), + migrations.AddField( + model_name='normajuridica', + name='norma_de_destaque', + field=models.BooleanField(choices=[(True, 'Sim'), (False, 'Não')], default=False, verbose_name='Norma de Destaque ?'), + ), + ] diff --git a/sapl/norma/models.py b/sapl/norma/models.py index 6b3a18a1f..52e797165 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -138,6 +138,13 @@ class NormaJuridica(models.Model): through_fields=('norma', 'autor'), symmetrical=False) + norma_de_destaque = models.BooleanField(verbose_name=_('Norma de Destaque ?'), + choices=YES_NO_CHOICES, + default=False) + + apelido = models.TextField( + blank=True, verbose_name=_('Apelido')) + class Meta: verbose_name = _('Norma Jurídica') verbose_name_plural = _('Normas Jurídicas') diff --git a/sapl/norma/urls.py b/sapl/norma/urls.py index 800707915..b25c77c5a 100644 --- a/sapl/norma/urls.py +++ b/sapl/norma/urls.py @@ -1,6 +1,6 @@ from django.conf.urls import include, url -from sapl.norma.views import (AnexoNormaJuridicaCrud,AssuntoNormaCrud, NormaCrud, NormaPesquisaView, +from sapl.norma.views import (AnexoNormaJuridicaCrud,AssuntoNormaCrud, NormaCrud, NormaPesquisaView, NormaDestaquesView, NormaRelacionadaCrud, NormaTaView, TipoNormaCrud, TipoVinculoNormaJuridicaCrud, recuperar_norma, recuperar_numero_norma, AutoriaNormaCrud) @@ -26,6 +26,9 @@ urlpatterns = [ url(r'^norma/pesquisar$', NormaPesquisaView.as_view(), name='norma_pesquisa'), + url(r'^norma/destaques$', + NormaDestaquesView.as_view(), name='norma_de_destaque'), + url(r'^norma/recuperar-norma$', recuperar_norma, name="recuperar_norma"), url(r'^norma/recuperar-numero-norma$', recuperar_numero_norma, name="recuperar_numero_norma"), diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 735d595a3..9dde99eb3 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -8,7 +8,7 @@ from django.http import HttpResponse, JsonResponse from django.template import RequestContext, loader from django.utils import timezone from django.utils.translation import ugettext_lazy as _ -from django.views.generic import TemplateView, UpdateView +from django.views.generic import TemplateView, UpdateView, ListView from django.views.generic.base import RedirectView from django.views.generic.edit import FormView from django_filters.views import FilterView @@ -67,6 +67,13 @@ class NormaRelacionadaCrud(MasterDetailCrud): layout_key = 'NormaRelacionadaDetail' +class NormaDestaquesView(ListView): + model = NormaJuridica + template_name = 'norma/normajuridica_destaques.html' + paginate_by = 1000 + + def get_queryset(self): + return NormaJuridica.objects.filter(norma_de_destaque=True) class NormaPesquisaView(FilterView): model = NormaJuridica diff --git a/sapl/templates/navbar.yaml b/sapl/templates/navbar.yaml index b5e11a036..f8c487c51 100644 --- a/sapl/templates/navbar.yaml +++ b/sapl/templates/navbar.yaml @@ -67,6 +67,8 @@ children: - title: {% trans 'Pesquisar Normas Jurídicas' %} url: sapl.norma:norma_pesquisa + - title: {% trans 'Normas de Destaque' %} + url: sapl.norma:norma_de_destaque - title: {% trans 'Adicionar Norma Jurídica' %} url: 'sapl.norma:normajuridica_create' check_permission: norma.add_normajuridica diff --git a/sapl/templates/norma/layouts.yaml b/sapl/templates/norma/layouts.yaml index 90be4172e..ab22617d7 100644 --- a/sapl/templates/norma/layouts.yaml +++ b/sapl/templates/norma/layouts.yaml @@ -20,6 +20,7 @@ NormaJuridica: - data_publicacao veiculo_publicacao data_vigencia pagina_inicio_publicacao pagina_fim_publicacao - texto_integral - ementa + - apelido - indexacao - observacao - assuntos @@ -33,11 +34,12 @@ AnexoNormaJuridica: NormaJuridicaCreate: {% trans 'Identificação Básica' %}: - tipo ano numero - - data esfera_federacao complemento + - data esfera_federacao complemento norma_de_destaque - tipo_materia numero_materia ano_materia - data_publicacao veiculo_publicacao data_vigencia pagina_inicio_publicacao pagina_fim_publicacao - texto_integral - ementa + - apelido - indexacao - observacao - assuntos diff --git a/sapl/templates/norma/normajuridica_destaques.html b/sapl/templates/norma/normajuridica_destaques.html new file mode 100644 index 000000000..dcf16478f --- /dev/null +++ b/sapl/templates/norma/normajuridica_destaques.html @@ -0,0 +1,38 @@ +{% extends "norma/normajuridica_filter.html" %} +{% load i18n %} + +{% block detail_content %} +{% endblock detail_content %} + +{% block table_content %} +
Tipo | +Número | +Ano | +Data | +Ementa | +Apelido | +|
---|---|---|---|---|---|---|
{{n.tipo}} | + {% if n.texto_integral %} +{{n.numero}} | + {% else %} +{{n.numero}} | + {% endif %} +{{n.ano}} | +{{n.data}} | +{{n.ementa|safe}} | +{{n.apelido|safe}} | +