From 77a52c361d5ae3024ba83e1c08da9a2ddf53dc86 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Sat, 27 Feb 2021 21:41:27 -0300 Subject: [PATCH] =?UTF-8?q?refatora=20norma=20e=20compila=C3=A7=C3=A3o=20p?= =?UTF-8?q?ara=20sapl=20as=20sapn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/templatetags/common_tags.py | 15 +++++++++++---- sapl/norma/views.py | 8 ++++++-- sapl/templates/base.html | 2 +- sapl/templates/compilacao/subnav.html | 4 +++- .../templates/compilacao/text_list__embedded.html | 3 +++ .../compilacao/textoarticulado_detail.html | 6 +++--- sapl/templates/norma/normajuridica_detail.html | 6 +++--- sapl/urls.py | 8 ++------ 8 files changed, 32 insertions(+), 20 deletions(-) diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index 048778d8d..56d7d356e 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/sapl/base/templatetags/common_tags.py @@ -51,6 +51,13 @@ def model_verbose_name_plural(class_name): model = get_class(class_name) return model._meta.verbose_name_plural +@register.filter +def meta_model_value(instance, attr): + try: + return getattr(instance._meta, attr) + except: + return '' + @register.filter def split(value, arg): @@ -324,12 +331,12 @@ def render_chunk_vendors(extension=None): return mark_safe('\n'.join(tags)) except: return '' - - + + @register.filter(is_safe=True) -@stringfilter +@stringfilter def dont_break_out(value): _safe = '
{}
'.format(value) _safe = mark_safe(_safe) - return _safe + return _safe diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 1281f9d76..6173ab832 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -7,6 +7,7 @@ from django.core.exceptions import ObjectDoesNotExist from django.db.models import Q from django.http import HttpResponse, JsonResponse from django.http.response import HttpResponseRedirect +from django.shortcuts import redirect from django.template import RequestContext, loader from django.urls import reverse from django.urls.base import reverse_lazy @@ -35,8 +36,6 @@ from .models import (AnexoNormaJuridica, AssuntoNorma, NormaJuridica, NormaRelac # LegislacaoCitadaCrud = Crud.build(LegislacaoCitada, '') - - TipoNormaCrud = CrudAux.build( TipoNormaJuridica, 'tipo_norma_juridica', list_field_names=['sigla', 'descricao', 'equivalente_lexml']) @@ -273,6 +272,11 @@ class NormaCrud(Crud): norma_id=kwargs['pk'], ano=timezone.now().year, horario_acesso=timezone.now()) + + if not 'display' in request.GET and not request.user.has_perm('norma.change_normajuridica') and \ + self.get_object().texto_articulado.exists(): + return redirect(reverse('sapl.norma:norma_ta', + kwargs={'pk': self.kwargs['pk']})) return super().get(request, *args, **kwargs) class DeleteView(Crud.DeleteView): diff --git a/sapl/templates/base.html b/sapl/templates/base.html index 7bf3975ef..e027a5e29 100644 --- a/sapl/templates/base.html +++ b/sapl/templates/base.html @@ -66,7 +66,7 @@