Browse Source

Exclui legacy da busca por ContentType p TipoAutor

Bugfix para migrações de vários bancos
pull/937/head
Marcio Mazza 8 years ago
parent
commit
cedb6cc159
  1. 13
      sapl/legacy/migration.py

13
sapl/legacy/migration.py

@ -386,12 +386,13 @@ class DataMigrator:
setattr(new, field.name, value) setattr(new, field.name, value)
elif field.model.__name__ == 'TipoAutor' and \ elif field.model.__name__ == 'TipoAutor' and \
field.name == 'content_type': field.name == 'content_type':
try:
value = field.related_model.objects.get( model = normalize(new.descricao.lower()).replace(' ', '')
model=normalize(new.descricao.lower()).replace(' ', content_types = field.related_model.objects.filter(
'')) model=model).exclude(app_label='legacy')
except ObjectDoesNotExist: assert len(content_types) <= 1
value = None
value = content_types[0] if content_types else None
setattr(new, field.name, value) setattr(new, field.name, value)
def migrate(self, obj=appconfs, interativo=True): def migrate(self, obj=appconfs, interativo=True):

Loading…
Cancel
Save