Browse Source

Merge pull request #1161 from interlegis/1160-add-autor-no-grupo

fix #1160 - Adiciona autores em Group model
pull/1162/head
Luciano Henrique Nunes de Almeida 8 years ago
committed by GitHub
parent
commit
b9c3fde65f
  1. 8
      sapl/legacy/migration.py

8
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(

Loading…
Cancel
Save