From cedb6cc15979d03fd4e479401f47fa089d10f755 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Tue, 14 Mar 2017 19:41:02 -0300 Subject: [PATCH] Exclui legacy da busca por ContentType p TipoAutor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bugfix para migrações de vários bancos --- sapl/legacy/migration.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index c7bad24d9..e42fd5fe4 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -386,12 +386,13 @@ class DataMigrator: setattr(new, field.name, value) elif field.model.__name__ == 'TipoAutor' and \ field.name == 'content_type': - try: - value = field.related_model.objects.get( - model=normalize(new.descricao.lower()).replace(' ', - '')) - except ObjectDoesNotExist: - value = None + + model = normalize(new.descricao.lower()).replace(' ', '') + content_types = field.related_model.objects.filter( + model=model).exclude(app_label='legacy') + assert len(content_types) <= 1 + + value = content_types[0] if content_types else None setattr(new, field.name, value) def migrate(self, obj=appconfs, interativo=True):