mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Replace the role fixup post_migrate handler with a data migration
This commit is contained in:
parent
15b7ad3570
commit
e524d3df3e
18
awx/main/migrations/0174_ensure_org_ee_admin_roles.py
Normal file
18
awx/main/migrations/0174_ensure_org_ee_admin_roles.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.16 on 2022-12-07 21:11
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
from awx.main.migrations import _rbac as rbac
|
||||
from awx.main.migrations import _migration_utils as migration_utils
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0173_instancegroup_max_limits'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(migration_utils.set_current_apps_for_migrations),
|
||||
migrations.RunPython(rbac.create_roles),
|
||||
]
|
||||
@ -17,7 +17,6 @@ from django.db.models.signals import (
|
||||
pre_delete,
|
||||
post_delete,
|
||||
m2m_changed,
|
||||
post_migrate,
|
||||
)
|
||||
from django.dispatch import receiver
|
||||
from django.contrib.auth import SESSION_KEY
|
||||
@ -110,19 +109,6 @@ def emit_update_inventory_on_created_or_deleted(sender, **kwargs):
|
||||
connection.on_commit(lambda: update_inventory_computed_fields.delay(inventory.id))
|
||||
|
||||
|
||||
def fixup_missing_org_ee_admin_roles(app_config, **kwargs):
|
||||
if app_config.label != 'main':
|
||||
return
|
||||
|
||||
print("Fixing up missing EE admin roles.")
|
||||
with disable_activity_stream():
|
||||
for org in Organization.objects.all():
|
||||
org.save()
|
||||
|
||||
|
||||
post_migrate.connect(fixup_missing_org_ee_admin_roles)
|
||||
|
||||
|
||||
def rebuild_role_ancestor_list(reverse, model, instance, pk_set, action, **kwargs):
|
||||
'When a role parent is added or removed, update our role hierarchy list'
|
||||
if action == 'post_add':
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user