Browse Source

1934 ordenar protocolo (#2033)

* 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
pull/2039/head
Talitha Pumar 7 years ago
committed by Edward
parent
commit
3b3b4acf72
  1. 31
      sapl/base/templatetags/common_tags.py
  2. 31
      sapl/templates/materia/prop_pendentes_list.html

31
sapl/base/templatetags/common_tags.py

@ -3,7 +3,7 @@ from django import template
from django.template.defaultfilters import stringfilter from django.template.defaultfilters import stringfilter
from sapl.base.models import AppConfig 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.norma.models import NormaJuridica
from sapl.parlamentares.models import Filiacao from sapl.parlamentares.models import Filiacao
from sapl.utils import filiacao_data from sapl.utils import filiacao_data
@ -11,6 +11,11 @@ from sapl.utils import filiacao_data
register = template.Library() register = template.Library()
@register.simple_tag
def define(arg):
return arg
@register.simple_tag @register.simple_tag
def field_verbose_name(instance, field_name): def field_verbose_name(instance, field_name):
return instance._meta.get_field(field_name).verbose_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 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 @register.filter
def lookup(d, key): def lookup(d, key):
return d[key] if key in d else [] return d[key] if key in d else []

31
sapl/templates/materia/prop_pendentes_list.html

@ -11,24 +11,42 @@
<table class="table table-striped table-hover"> <table class="table table-striped table-hover">
<thead> <thead>
<tr> <tr>
<th>Data de Envio</th> {% with 'Data Envio,Tipo,Descrição,Autor' as list %}
<th>Tipo</th> {% for name in list|split:"," %}
<th>Descrição</th> <th>
<th>Autor</th> <a title="{% trans 'Clique para alterar a ordem a listagem'%}" href="?o={% if 'o' not in request.GET and forloop.counter == 1 or 'o' in request.GET and forloop.counter|safe == request.GET.o %}-{%endif%}{{forloop.counter}}">
{{ 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 %}
<span class="caret top" title="{% trans 'Listado na Ordem Ascendente'%}"></span>
{% elif 'o' in request.GET and forloop.counter == request.GET.o|str2intabs %}
<span class="caret" title="{% trans 'Listado na Ordem Descendente'%}"></span>
{%endif%}
{%endif%}
</a>
</th>
{% endfor %}
{% if not AppConfig.receber_recibo_proposicao %} {% if not AppConfig.receber_recibo_proposicao %}
<th>Código do Documento</th> <th>Código do Documento</th>
{% endif %} {% endif %}
{% endwith %}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% 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 %}
<tr> <tr>
<td> <td>
<a href="{% url 'sapl.materia:proposicao_detail' prop.pk %}">{{ prop.data_envio|localtime|date:"d/m/Y H:i:s" }}</a> <a href="{% url 'sapl.materia:proposicao_detail' prop.pk %}">{{ prop.data_envio|localtime|date:"d/m/Y H:i:s" }}</a>
</td> </td>
<td>{{ prop.tipo.descricao }}</td> <td>{{ prop.tipo.descricao }}</td>
<td>{{ prop.descricao }}</td> <td>{{ prop.descricao }}</td>
<td>{{prop.autor}}</td> <td>{{ prop.autor }}</td>
<td> <td>
{% if not AppConfig.receber_recibo_proposicao %} {% if not AppConfig.receber_recibo_proposicao %}
{%if prop.hash_code %} {%if prop.hash_code %}
@ -44,5 +62,6 @@
</table> </table>
{% endif %} {% endif %}
</fieldset> </fieldset>
{% include 'paginacao.html'%} {% include 'paginacao.html'%}
{% endblock %} {% endblock %}

Loading…
Cancel
Save