From 15b7ad3570b5d84f14a2ee0bcccf9d4491524e16 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Wed, 7 Dec 2022 15:57:20 -0500 Subject: [PATCH] Add a post_migrate signal handler to rebuild the Org roles particularly, the execution_environment_admin_role. --- awx/main/signals.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/awx/main/signals.py b/awx/main/signals.py index 58ab17c95e..1b4a1b0b76 100644 --- a/awx/main/signals.py +++ b/awx/main/signals.py @@ -17,6 +17,7 @@ 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 @@ -109,6 +110,19 @@ 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':