From 3b3b4acf72ade7640060d5a511e94ce04db8df2f Mon Sep 17 00:00:00 2001 From: Talitha Pumar Date: Thu, 21 Jun 2018 12:55:26 -0300 Subject: [PATCH] 1934 ordenar protocolo (#2033) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix #1934 ordenaçao na tela de proposiçoes pendentes * Fix #1934 ordenaçao na tela de proposiçoes pendentes * --amend * Update more pythonic * Update prop_pendentes_list.html --- sapl/base/templatetags/common_tags.py | 31 ++++++++++++++++++- .../materia/prop_pendentes_list.html | 31 +++++++++++++++---- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index 9e095f072..73d71faa8 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/sapl/base/templatetags/common_tags.py @@ -3,7 +3,7 @@ from django import template from django.template.defaultfilters import stringfilter from sapl.base.models import AppConfig -from sapl.materia.models import DocumentoAcessorio, MateriaLegislativa +from sapl.materia.models import DocumentoAcessorio, MateriaLegislativa, Proposicao from sapl.norma.models import NormaJuridica from sapl.parlamentares.models import Filiacao from sapl.utils import filiacao_data @@ -11,6 +11,11 @@ from sapl.utils import filiacao_data register = template.Library() +@register.simple_tag +def define(arg): + return arg + + @register.simple_tag def field_verbose_name(instance, field_name): return instance._meta.get_field(field_name).verbose_name @@ -34,6 +39,30 @@ def model_verbose_name_plural(class_name): return model._meta.verbose_name_plural +@register.filter +def split(value, arg): + return value.split(arg) + + +@register.filter +def sort_by_keys(value, key): + transformed = [] + id_props = [x.id for x in value] + qs = Proposicao.objects.filter(pk__in=id_props) + key_descricao = {'1': 'data_envio', + '-1': '-data_envio', + '2': 'tipo', + '-2': '-tipo', + '3': 'descricao', + '-3': '-descricao', + '4': 'autor', + '-4': '-autor' + } + + transformed = qs.order_by(key_descricao[key]) + return transformed + + @register.filter def lookup(d, key): return d[key] if key in d else [] diff --git a/sapl/templates/materia/prop_pendentes_list.html b/sapl/templates/materia/prop_pendentes_list.html index 092d19a26..518ba7601 100644 --- a/sapl/templates/materia/prop_pendentes_list.html +++ b/sapl/templates/materia/prop_pendentes_list.html @@ -11,24 +11,42 @@ - - - - + {% with 'Data Envio,Tipo,Descrição,Autor' as list %} + {% for name in list|split:"," %} + + {% endfor %} {% if not AppConfig.receber_recibo_proposicao %} {% endif %} + {% endwith %} - {% for prop in object_list %} + {% if 'o' in request.GET %} + {% define object_list|sort_by_keys:request.GET.o as list %} + {% else %} + {% define object_list as list %} + {% endif %} + + {% for prop in list %} - +
Data de EnvioTipoDescriçãoAutor + + {{ name }} + {% if 'o' in request.GET %} + {% if 'o' not in request.GET and forloop.counter == 1 or 'o' in request.GET and forloop.counter|safe == request.GET.o %} + + {% elif 'o' in request.GET and forloop.counter == request.GET.o|str2intabs %} + + {%endif%} + {%endif%} + + Código do Documento
{{ prop.data_envio|localtime|date:"d/m/Y H:i:s" }} {{ prop.tipo.descricao }} {{ prop.descricao }}{{prop.autor}}{{ prop.autor }} {% if not AppConfig.receber_recibo_proposicao %} {%if prop.hash_code %} @@ -44,5 +62,6 @@
{% endif %} + {% include 'paginacao.html'%} {% endblock %}