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 %} +
+ {% trans 'Voltar para pesquisa' %} +
+{% endblock %} \ No newline at end of file