Browse Source

Fix #1874 removendo acento (#1923)

* Fix #1874 removendo acento

* Fix #1874 sem remover acentos
pull/1932/head
Victor Fabre 7 years ago
committed by Edward
parent
commit
05145d0d6e
  1. 10
      sapl/sessao/views.py
  2. 2
      sapl/templates/sessao/mesa.html
  3. 3
      sapl/utils.py

10
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,

2
sapl/templates/sessao/mesa.html

@ -38,7 +38,7 @@
<label id='parlamentar-cargo-title' style="display: none">Parlamentar | Cargo</label>
<select class="form-control" name="parlamentar" id="id_parlamentar" style="display: none">
{% for p in parlamentares %}
<option value="{{p.id}}">{{p.nome_completo}}</option>
<option value="{{p.id}}">{{p.nome_parlamentar}}</option>
{% endfor %}
</select>
<br />

3
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'])
return unicodedata.normalize('NFKD', string).encode('ASCII', 'ignore').decode()
Loading…
Cancel
Save