Make use of 'current' apps so RBAC ImplicitRoleField can work during migrations

While a migration is taking place, we can't juse use normal model
references like Role and RolePermission, nor can we use generic foreign
keys without manually referring to the content type and object id
fields.
This commit is contained in:
Akita Noek
2016-04-10 11:57:39 -04:00
parent 682552d9b0
commit 7d2e660749
4 changed files with 52 additions and 9 deletions

View File

@@ -5,7 +5,7 @@ from django.db.models import Q
from django.utils.timezone import now
from collections import defaultdict
from awx.main.utils import getattrd
from awx.main.utils import getattrd, set_current_apps
import _old_access as old_access
logger = logging.getLogger(__name__)
@@ -26,6 +26,10 @@ def log_migration(wrapped):
return wrapped(*args, **kwargs)
return wrapper
@log_migration
def init_rbac_migration(apps, schema_editor):
set_current_apps(apps)
@log_migration
def migrate_users(apps, schema_editor):
User = apps.get_model('auth', "User")