From c195a8e7cbcc65353b55adba86329f93158940af Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Thu, 16 Apr 2015 18:25:01 -0300 Subject: [PATCH] Constrain codigo_interlegis to only ascii upper --- sigi/apps/casas/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sigi/apps/casas/models.py b/sigi/apps/casas/models.py index 8d2ab33..c1e5dab 100644 --- a/sigi/apps/casas/models.py +++ b/sigi/apps/casas/models.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import random +from string import ascii_uppercase from unicodedata import normalize from datetime import datetime @@ -155,6 +156,7 @@ class CasaLegislativa(models.Model): cityName = cityName.replace(' DA ', ' ') cityName = cityName.replace(' DE ', ' ') cityName = cityName.replace(' DO ', ' ') + cityName = filter(lambda x: x in ascii_uppercase + ' ', cityName) # estratégia 1 - Pegar as 1ª letra de cada nome da cidade codigo = ''.join([x[0] for x in cityName.split(' ')[:3]])