From 8adfe1170c501117c5c7614120ad13641bb7a62b Mon Sep 17 00:00:00 2001 From: LeandroJatai Date: Sun, 31 Jul 2022 20:13:37 -0300 Subject: [PATCH] impl field resumo em NormaRelacionada --- sapl/norma/forms.py | 23 +++++++++++-------- .../0040_normarelacionada_resumo.py | 18 +++++++++++++++ sapl/norma/models.py | 5 ++++ sapl/norma/views.py | 7 +++--- sapl/templates/norma/layouts.yaml | 2 ++ 5 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 sapl/norma/migrations/0040_normarelacionada_resumo.py diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index a8d80c7b9..026d49842 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -1,6 +1,5 @@ import logging -import django_filters from crispy_forms.layout import (Button, Fieldset, HTML, Layout) from django import forms from django.contrib.postgres.search import SearchVector @@ -9,6 +8,7 @@ from django.db.models import Q from django.forms import ModelChoiceField, ModelForm, widgets from django.utils import timezone from django.utils.translation import ugettext_lazy as _ +import django_filters from sapl.base.models import TipoAutor from sapl.crispy_layout_mixin import form_actions, SaplFormHelper, to_row @@ -18,6 +18,7 @@ from sapl.parlamentares.models import Partido from sapl.utils import (autor_label, autor_modal, ANO_CHOICES, choice_anos_com_normas, FileFieldCheckMixin, FilterOverridesMetaMixin, NormaPesquisaOrderingFilter, validar_arquivo) + from .models import (AnexoNormaJuridica, AssuntoNorma, AutoriaNorma, NormaJuridica, NormaRelacionada, TipoNormaJuridica) @@ -121,20 +122,20 @@ class NormaFilterSet(django_filters.FilterSet): self.form.helper.layout = Layout( Fieldset(_('Pesquisa de Norma'), row1, row2, row3, row4, row5, - Fieldset(_('Pesquisa Avançada'), - row6, - HTML(autor_label), - HTML(autor_modal)), + Fieldset(_('Pesquisa Avançada'), + row6, + HTML(autor_label), + HTML(autor_modal)), form_actions(label='Pesquisar')) ) def filter_ementa(self, queryset, name, value): return queryset.annotate(search=SearchVector('ementa', - config='portuguese')).filter(search=value) + config='portuguese')).filter(search=value) def filter_indexacao(self, queryset, name, value): return queryset.annotate(search=SearchVector('indexacao', - config='portuguese')).filter(search=value) + config='portuguese')).filter(search=value) def filter_autoria(self, queryset, name, value): return queryset.filter(**{ @@ -308,7 +309,6 @@ class AutoriaNormaForm(ModelForm): if not self.instance: self.fields['autor'].choices = [] - class Meta: model = AutoriaNorma fields = ['tipo_autor', 'autor', @@ -397,7 +397,12 @@ class NormaRelacionadaForm(ModelForm): class Meta: model = NormaRelacionada - fields = ['orgao', 'tipo', 'numero', 'ano', 'ementa', 'tipo_vinculo'] + fields = ['orgao', 'tipo', 'numero', 'ano', + 'resumo', 'ementa', 'tipo_vinculo'] + + widgets = { + 'resumo': forms.Textarea( + attrs={'id': 'texto-rico'})} def __init__(self, *args, **kwargs): super(NormaRelacionadaForm, self).__init__(*args, **kwargs) diff --git a/sapl/norma/migrations/0040_normarelacionada_resumo.py b/sapl/norma/migrations/0040_normarelacionada_resumo.py new file mode 100644 index 000000000..1d2d14cd4 --- /dev/null +++ b/sapl/norma/migrations/0040_normarelacionada_resumo.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.28 on 2022-07-31 23:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0039_auto_20220321_0934'), + ] + + operations = [ + migrations.AddField( + model_name='normarelacionada', + name='resumo', + field=models.TextField(blank=True, default='', verbose_name='Resumo'), + ), + ] diff --git a/sapl/norma/models.py b/sapl/norma/models.py index 2e15cf333..a24c7ac86 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -407,6 +407,11 @@ class NormaRelacionada(models.Model): TipoVinculoNormaJuridica, on_delete=models.PROTECT, verbose_name=_('Tipo de Vínculo')) + resumo = models.TextField( + blank=True, + default="", + verbose_name=_('Resumo'), + ) class Meta: verbose_name = _('Norma Relacionada') diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 256399256..bccd5e328 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -100,10 +100,11 @@ class PesquisarAssuntoNormaView(FilterView): if data: url = '&' + str(self.request.META["QUERY_STRING"]) if url.startswith("&page"): - url = '' + url = '' if 'assunto' in self.request.META['QUERY_STRING'] or\ - 'page' in self.request.META['QUERY_STRING']: resultados = self.object_list + 'page' in self.request.META['QUERY_STRING']: + resultados = self.object_list else: resultados = [] @@ -125,7 +126,7 @@ class NormaRelacionadaCrud(MasterDetailCrud): help_topic = 'norma_juridica' class BaseMixin(MasterDetailCrud.BaseMixin): - list_field_names = ['norma_relacionada', 'tipo_vinculo'] + list_field_names = ['norma_relacionada', 'tipo_vinculo', 'resujmo'] class CreateView(MasterDetailCrud.CreateView): form_class = NormaRelacionadaForm diff --git a/sapl/templates/norma/layouts.yaml b/sapl/templates/norma/layouts.yaml index a957e10a6..0ea7cea51 100644 --- a/sapl/templates/norma/layouts.yaml +++ b/sapl/templates/norma/layouts.yaml @@ -65,11 +65,13 @@ NormaRelacionada: - orgao tipo:4 numero:3 ano:2 - tipo_vinculo - ementa + - resumo NormaRelacionadaDetail: {% trans 'Norma Relacionada' %}: - norma_relacionada - tipo_vinculo + - resumo AutoriaNorma: {% trans 'Autoria' %}: