From 5f637b73c823d063bb6b430879ee9eabbe33556c Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Fri, 2 Oct 2020 09:02:03 -0300 Subject: [PATCH] =?UTF-8?q?insere=20listagem=20de=20normas=20que=20possuem?= =?UTF-8?q?=20TAs=20n=C3=A3o=20publicados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/norma/views.py | 25 ++++++++++++++----- .../templates/norma/normajuridica_filter.html | 9 +++++-- sapl/templates/norma/normajuridica_list.html | 9 +++++++ 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 sapl/templates/norma/normajuridica_list.html diff --git a/sapl/norma/views.py b/sapl/norma/views.py index c10efe912..02d57990c 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -4,6 +4,7 @@ import re from django.contrib.auth.mixins import PermissionRequiredMixin from django.core.exceptions import ObjectDoesNotExist +from django.db.models import Q from django.http import HttpResponse, JsonResponse from django.template import RequestContext, loader from django.urls import reverse @@ -242,14 +243,26 @@ class NormaCrud(Crud): layout_key = 'NormaJuridicaCreate' - class ListView(Crud.ListView, RedirectView): + class ListView(Crud.ListView): - def get_redirect_url(self, *args, **kwargs): - namespace = self.model._meta.app_config.name - return reverse('%s:%s' % (namespace, 'norma_pesquisa')) + def get_queryset(self): + qs = Crud.ListView.get_queryset(self) + q = Q( + texto_articulado__privacidade=0 + ) | Q( + texto_articulado__isnull=True) + qs = qs.exclude(q) + return qs.order_by('-texto_articulado__privacidade', '-ano', '-numero') - def get(self, request, *args, **kwargs): - return RedirectView.get(self, request, *args, **kwargs) + def get_context_data(self, **kwargs): + context = Crud.ListView.get_context_data(self, **kwargs) + + context['title'] = 'Normas Jurídicas com Textos Articulados não publicados' + return context + + @classmethod + def get_url_regex(cls): + return r'^check_compilacao$' class UpdateView(Crud.UpdateView): form_class = NormaJuridicaForm diff --git a/sapl/templates/norma/normajuridica_filter.html b/sapl/templates/norma/normajuridica_filter.html index cad3c5f8f..d8eef093b 100644 --- a/sapl/templates/norma/normajuridica_filter.html +++ b/sapl/templates/norma/normajuridica_filter.html @@ -3,14 +3,19 @@ {% load crispy_forms_tags %} {% block actions %} +
+ {% if perms.compilacao.lock_unlock_textoarticulado %} + + {% blocktrans with verbose_name=view.verbose_name %}Pendências nos Textos Articulados{% endblocktrans %} + + {% endif %} +
{% if USE_SOLR %} Pesquisa Textual {% endif %} - - {% if perms.norma.add_normajuridica %} {% blocktrans with verbose_name=view.verbose_name %} Adicionar Norma Jurídica {% endblocktrans %} diff --git a/sapl/templates/norma/normajuridica_list.html b/sapl/templates/norma/normajuridica_list.html new file mode 100644 index 000000000..34e0e8e0a --- /dev/null +++ b/sapl/templates/norma/normajuridica_list.html @@ -0,0 +1,9 @@ +{% extends "crud/list.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block extra_actions %} + +{% endblock %} \ No newline at end of file