mirror of
https://github.com/ansible/awx.git
synced 2026-06-27 09:28:01 -02:30
AAP-48392 Handle DAB RBAC either before or after new type model (for merge) (#16045)
* Handle DAB RBAC either before or after new type model * Translate CT to DAB CT * Fixes for content type switch * Use more compatible coding pattern * Deeper purge of content_type_id * revert, turns out that did not work * More content type replacements * Revert changes to serializer * Revert another content_type change * Fix for rearrangement of post_migration methods * Remove thing I am not going to do * Revert branch pin that was temporary
This commit is contained in:
@@ -17,7 +17,13 @@ logger = logging.getLogger('awx.main.migrations._dab_rbac')
|
||||
|
||||
|
||||
def create_permissions_as_operation(apps, schema_editor):
|
||||
# NOTE: the DAB ContentType changes adjusted how they fire
|
||||
# before they would fire on every app config, like contenttypes
|
||||
create_dab_permissions(global_apps.get_app_config("main"), apps=apps)
|
||||
# This changed to only fire once and do a global creation
|
||||
# so we need to call it for specifically the dab_rbac app
|
||||
# multiple calls will not hurt anything
|
||||
create_dab_permissions(global_apps.get_app_config("dab_rbac"), apps=apps)
|
||||
|
||||
|
||||
"""
|
||||
@@ -112,7 +118,12 @@ def get_descendents(f, children_map):
|
||||
|
||||
def get_permissions_for_role(role_field, children_map, apps):
|
||||
Permission = apps.get_model('dab_rbac', 'DABPermission')
|
||||
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||||
try:
|
||||
# After migration for remote permissions
|
||||
ContentType = apps.get_model('dab_rbac', 'DABContentType')
|
||||
except LookupError:
|
||||
# If using DAB from before remote permissions are implemented
|
||||
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||||
|
||||
perm_list = []
|
||||
for child_field in get_descendents(role_field, children_map):
|
||||
@@ -281,7 +292,13 @@ def setup_managed_role_definitions(apps, schema_editor):
|
||||
'special': '{cls.__name__} {action}',
|
||||
}
|
||||
|
||||
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||||
try:
|
||||
# After migration for remote permissions
|
||||
ContentType = apps.get_model('dab_rbac', 'DABContentType')
|
||||
except LookupError:
|
||||
# If using DAB from before remote permissions are implemented
|
||||
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||||
|
||||
Permission = apps.get_model('dab_rbac', 'DABPermission')
|
||||
RoleDefinition = apps.get_model('dab_rbac', 'RoleDefinition')
|
||||
Organization = apps.get_model(settings.ANSIBLE_BASE_ORGANIZATION_MODEL)
|
||||
|
||||
Reference in New Issue
Block a user