diff options
author | Jeff Bradberry <jeff.bradberry@gmail.com> | 2024-06-07 20:01:08 +0200 |
---|---|---|
committer | Jeff Bradberry <jeff.bradberry@gmail.com> | 2024-06-10 22:36:22 +0200 |
commit | aadcc217ebab7064ad9e6d9542d9505c8f32b40e (patch) | |
tree | f551f0ac618c19ec1c4eb431bee143dabb570fb5 /tools | |
parent | Guard against the role field not being populated (diff) | |
download | awx-aadcc217ebab7064ad9e6d9542d9505c8f32b40e.tar.xz awx-aadcc217ebab7064ad9e6d9542d9505c8f32b40e.zip |
This should deal correctly with the ancestor list mismatches
Diffstat (limited to 'tools')
-rw-r--r-- | tools/scripts/ig-hotfix/role_check.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/scripts/ig-hotfix/role_check.py b/tools/scripts/ig-hotfix/role_check.py index ef2e67b9c0..7da16b1e1c 100644 --- a/tools/scripts/ig-hotfix/role_check.py +++ b/tools/scripts/ig-hotfix/role_check.py @@ -71,13 +71,13 @@ for r in Role.objects.exclude(role_field__startswith='system_').order_by('id'): sys.stderr.write(f"Role id={r.id} has no implicit_parents\n") if not parents <= ancestors: sys.stderr.write(f"Role id={r.id} has parents that are not in the ancestor list: {parents - ancestors}\n") - crosslinked[r.content_type_id][r.object_id] + crosslinked[r.content_type_id][r.object_id][f'{r.role_field}_id'] = r.id if not implicit <= parents: sys.stderr.write(f"Role id={r.id} has implicit_parents that are not in the parents list: {implicit - parents}\n") - crosslinked[r.content_type_id][r.object_id] + crosslinked[r.content_type_id][r.object_id][f'{r.role_field}_id'] = r.id if not implicit <= ancestors: sys.stderr.write(f"Role id={r.id} has implicit_parents that are not in the ancestor list: {implicit - ancestors}\n") - crosslinked[r.content_type_id][r.object_id] + crosslinked[r.content_type_id][r.object_id][f'{r.role_field}_id'] = r.id # Check that the Role's generic foreign key points to a legitimate object if not r.content_object: @@ -181,6 +181,7 @@ print(" obj = cls.objects.get(id=obj_id)") print(" for f in role_fields:") print(" r = getattr(obj, f.name, None)") print(" if r is not None:") +print(" print(f'updating implicit parents on Role {r.id}')") print(" r.implicit_parents = '[]'") print(" r.save()") print(" obj.save()") |