Add a post_migrate signal handler to rebuild the Org roles

particularly, the execution_environment_admin_role.
This commit is contained in:
Jeff Bradberry 2022-12-07 15:57:20 -05:00
parent a0b8215c06
commit 15b7ad3570

View File

@ -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':