Browse Source

Cria Normas de Destaque #2854 (#2874)

pull/2770/head
Rogério Frá 6 years ago
committed by Edward
parent
commit
134342b63f
  1. 15
      sapl/norma/forms.py
  2. 25
      sapl/norma/migrations/0025_auto_20190704_0816.py
  3. 7
      sapl/norma/models.py
  4. 5
      sapl/norma/urls.py
  5. 9
      sapl/norma/views.py
  6. 2
      sapl/templates/navbar.yaml
  7. 4
      sapl/templates/norma/layouts.yaml
  8. 38
      sapl/templates/norma/normajuridica_destaques.html

15
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):

25
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 ?'),
),
]

7
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')

5
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"),

9
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

2
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

4
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

38
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 %}
<table class="table table-striped">
<thead class="thead-default">
<tr>
<th>Tipo</th>
<th>Número</th>
<th>Ano</th>
<th>Data</th>
<th>Ementa</th>
<th>Apelido</th>
</tr>
</thead>
{% for n in page_obj %}
<tr>
<td><a href="{% url 'sapl.norma:normajuridica_detail' n.id %}">{{n.tipo}}</a></td>
{% if n.texto_integral %}
<td><a href="{{n.texto_integral.url}}">{{n.numero}}</a></td>
{% else %}
<td>{{n.numero}}</td>
{% endif %}
<td>{{n.ano}}</td>
<td>{{n.data}}</td>
<td>{{n.ementa|safe}}</td>
<td>{{n.apelido|safe}}</td>
</tr>
{% endfor %}
</table>
{% endblock table_content %}
{% block extra_js %}
{% endblock extra_js %}
Loading…
Cancel
Save