diff --git a/sapl/painel/views.py b/sapl/painel/views.py index 3f31e430d..4be056640 100644 --- a/sapl/painel/views.py +++ b/sapl/painel/views.py @@ -1,4 +1,3 @@ - from django.contrib import messages from django.contrib.auth.decorators import user_passes_test from django.core.exceptions import ObjectDoesNotExist @@ -8,6 +7,8 @@ from django.http import HttpResponse, JsonResponse from django.http.response import Http404, HttpResponseRedirect from django.shortcuts import render from django.utils.translation import ugettext_lazy as _ +from operator import itemgetter +from sapl.utils import sort_lista_chave from sapl.crud.base import Crud from sapl.painel.apps import AppConfig @@ -292,6 +293,8 @@ def get_presentes(pk, response, materia): elif materia.tipo_votacao == 3: tipo_votacao = 'Secreta' + presentes_list = sort_lista_chave(presentes_list, 'nome') + response.update({ 'presentes': presentes_list, 'num_presentes': num_presentes, diff --git a/sapl/utils.py b/sapl/utils.py index 7afa00d1a..37e5711d3 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -4,6 +4,7 @@ import os import re from functools import wraps from unicodedata import normalize as unicodedata_normalize +from operator import itemgetter import django_filters import magic @@ -651,3 +652,14 @@ def show_results_filter_set(qr): return False return True + + +def sort_lista_chave(lista, chave): + """ + :param lista: Uma list a ser ordenada . + :param chave: Algum atributo (chave) que está presente na lista e qual deve ser usado para a ordenação da nova + lista. + :return: A lista ordenada pela chave passada. + """ + lista_ordenada = sorted(lista, key=itemgetter(chave)) + return lista_ordenada