From a2fa3b62c4e6b4e14226033d48c36788afcb032c Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Fri, 2 Jun 2017 16:59:16 -0300 Subject: [PATCH] Adiciona autores em Group model Signed-off-by: Luciano Almeida --- sapl/legacy/migration.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index 8cb9bb37d..7794ca273 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -8,6 +8,7 @@ import yaml from django.apps import apps from django.apps.config import AppConfig from django.contrib.auth import get_user_model +from django.contrib.auth.models import Group from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ObjectDoesNotExist from django.db import OperationalError, ProgrammingError, connections, models @@ -755,6 +756,13 @@ def adjust_autor(new, old): with reversion.create_revision(): user.save() reversion.set_comment('Objeto criado pela migração') + + grupo_autor = Group.objects.get(name="Autor") + user.groups.add(grupo_autor) + if old.cod_parlamentar: + grupo_parlamentar = Group.objects.get(name="Parlamentar") + user.groups.add(grupo_parlamentar) + new.user = user else: new.user = get_user_model().objects.filter(