From 05145d0d6e93ad5e860f13f5289592c5b4ece6e8 Mon Sep 17 00:00:00 2001 From: Victor Fabre Date: Mon, 7 May 2018 14:28:59 -0300 Subject: [PATCH] Fix #1874 removendo acento (#1923) * Fix #1874 removendo acento * Fix #1874 sem remover acentos --- sapl/sessao/views.py | 10 ++++++---- sapl/templates/sessao/mesa.html | 2 +- sapl/utils.py | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index 746bbfec1..db3875677 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -4,7 +4,7 @@ from operator import itemgetter from django.contrib import messages from django.contrib.auth.decorators import permission_required from django.contrib.auth.mixins import PermissionRequiredMixin -from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist +from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse from django.db.models import Max, Q from django.forms.utils import ErrorList @@ -990,8 +990,8 @@ class MesaView(FormMixin, DetailView): set( [p.parlamentar for p in parlamentares]) - set( parlamentares_ocupados)) - - org_parlamentares_vagos = sorted(parlamentares_vagos, key=lambda x: x.nome_parlamentar) + org_parlamentares_vagos = parlamentares_vagos + org_parlamentares_vagos.sort(key=lambda x: remover_acentos(x.nome_parlamentar)) org_parlamentares_vagos = [p for p in org_parlamentares_vagos if p.ativo] # Se todos os cargos estiverem ocupados, a listagem de parlamentares # deve ser renderizada vazia @@ -1046,8 +1046,10 @@ def atualizar_mesa(request): lista_composicao = [(c.id, c.parlamentar.__str__(), c.cargo.__str__()) for c in composicao_mesa] lista_parlamentares = [( - p.id, p.__str__()) for p in parlamentares_vagos] + p.id, p.nome_parlamentar) + for p in parlamentares_vagos if p.ativo] lista_cargos = [(c.id, c.__str__()) for c in cargos_vagos] + lista_parlamentares.sort(key=lambda x: remover_acentos(x[1])) return JsonResponse( {'lista_composicao': lista_composicao, diff --git a/sapl/templates/sessao/mesa.html b/sapl/templates/sessao/mesa.html index 02f313656..56e7f9989 100644 --- a/sapl/templates/sessao/mesa.html +++ b/sapl/templates/sessao/mesa.html @@ -38,7 +38,7 @@
diff --git a/sapl/utils.py b/sapl/utils.py index 8045f0e0b..69ea53dfc 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -735,5 +735,4 @@ def RemoveTag(texto): return textoSaida def remover_acentos(string): - return ''.join([c for c in unicodedata.normalize('NFD', string) - if unicodedata.category(c) != 'Mn']) \ No newline at end of file + return unicodedata.normalize('NFKD', string).encode('ASCII', 'ignore').decode() \ No newline at end of file