misc: remove imports from django_rbac (#70971)
This commit is contained in:
parent
0d46b00c2f
commit
359ecaacef
|
@ -35,7 +35,12 @@ class AppConfig(django.apps.AppConfig):
|
|||
def post_migrate(self, verbosity=2, interactive=True, using=DEFAULT_DB_ALIAS, **kwargs):
|
||||
# create custom operations
|
||||
from authentic2.a2_rbac.models import Operation
|
||||
from django_rbac.utils import get_operation
|
||||
|
||||
try:
|
||||
from authentic2.a2_rbac.utils import get_operation
|
||||
except ImportError:
|
||||
# legacy
|
||||
from django_rbac.utils import get_operation
|
||||
|
||||
if not router.allow_migrate(using, Operation):
|
||||
return
|
||||
|
@ -44,13 +49,13 @@ class AppConfig(django.apps.AppConfig):
|
|||
get_operation(FC_MANAGE_OP)
|
||||
|
||||
def ready(self):
|
||||
from authentic2.a2_rbac.models import OrganizationalUnit
|
||||
from django.db.models.signals import post_migrate, post_save
|
||||
from django_rbac.utils import get_ou_model
|
||||
|
||||
from . import api_views
|
||||
|
||||
post_migrate.connect(self.post_migrate, sender=self)
|
||||
post_save.connect(self.ou_post_save, sender=get_ou_model())
|
||||
post_save.connect(self.ou_post_save, sender=OrganizationalUnit)
|
||||
|
||||
def ou_post_save(self, sender, instance, raw, created, **kwargs):
|
||||
from .utils import update_roles
|
||||
|
|
|
@ -9,13 +9,18 @@ from authentic2.a2_rbac.models import (
|
|||
VIEW_OP,
|
||||
Operation,
|
||||
)
|
||||
from authentic2.a2_rbac.models import OrganizationalUnit as OU
|
||||
from authentic2.a2_rbac.models import Permission, Role
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django_rbac.utils import get_operation, get_ou_model, get_permission_model, get_role_model
|
||||
|
||||
OU = get_ou_model()
|
||||
Role = get_role_model()
|
||||
Permission = get_permission_model()
|
||||
try:
|
||||
from authentic2.a2_rbac.utils import get_operation
|
||||
except ImportError:
|
||||
# legacy
|
||||
from django_rbac.utils import get_operation
|
||||
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
|
|
|
@ -10,12 +10,11 @@ try:
|
|||
except ImportError:
|
||||
import pathlib2 as pathlib
|
||||
|
||||
from authentic2.a2_rbac.models import OrganizationalUnit as OU
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.management import call_command
|
||||
from django_rbac.utils import get_ou_model
|
||||
|
||||
User = get_user_model()
|
||||
OU = get_ou_model()
|
||||
TEST_DIR = pathlib.Path(__file__).parent
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue