From 59659d208ce1cc0a4d8e1a9bdfc60f034e96d48d Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Mon, 19 Feb 2018 19:00:20 -0300 Subject: [PATCH] =?UTF-8?q?Atualiza=20identifica=C3=A7=C3=A3o=20de=20timez?= =?UTF-8?q?ones?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/legacy/migration.py | 8 ++++++-- sapl/legacy/timezonesbrasil.py | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index 71cd0cd62..f903b90d2 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -17,6 +17,7 @@ from django.core.exceptions import ObjectDoesNotExist from django.db import connections, transaction from django.db.models import Count, Max from django.db.models.base import ModelBase +from pytz import timezone from sapl.base.models import AppConfig as AppConf from sapl.base.models import (Autor, ProblemaMigracao, TipoAutor, @@ -575,8 +576,11 @@ class DataMigrator: sigla_casa = match.group(1) with open(os.path.expanduser('~/sapl_dumps/tabela_timezones.yaml'), 'r') as arq: tabela_timezones = yaml.load(arq) - municipio, uf = tabela_timezones[sigla_casa] - self.timezone = get_timezone(municipio, uf) + municipio, uf, nome_timezone = tabela_timezones[sigla_casa] + if nome_timezone: + self.timezone = timezone(nome_timezone) + else: + self.timezone = get_timezone(municipio, uf) def populate_renamed_fields(self, new, old): renames = self.field_renames[type(new)] diff --git a/sapl/legacy/timezonesbrasil.py b/sapl/legacy/timezonesbrasil.py index 0095ee6f6..a9989f87d 100644 --- a/sapl/legacy/timezonesbrasil.py +++ b/sapl/legacy/timezonesbrasil.py @@ -147,6 +147,13 @@ TZ_CIDADES_AMAZONAS_E_PARA = [ Bujaru Senador José Porfírio Irituia + parauapebas + brejo grande do araguaia + santana do araguaia + ourilandia do norte + marituba + canaa dos carajas + goianesia do para '''), ('America/Santarem', ''' Santarém @@ -162,6 +169,7 @@ TZ_CIDADES_AMAZONAS_E_PARA = [ Porto de Moz Nhamundá Prainha + medicilandia '''), ] TZ_CIDADES_AMAZONAS_E_PARA = {normalizar_texto(cidade.strip()): tz @@ -170,6 +178,7 @@ TZ_CIDADES_AMAZONAS_E_PARA = {normalizar_texto(cidade.strip()): tz def get_nome_timezone(cidade, uf): + uf = uf.upper() tz = UF_PARA_TIMEZONE[uf] if uf in ['PA', 'AM']: cidade = normalizar_texto(cidade)