From aadcc217ebab7064ad9e6d9542d9505c8f32b40e Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Fri, 7 Jun 2024 14:01:08 -0400 Subject: [PATCH] This should deal correctly with the ancestor list mismatches --- tools/scripts/ig-hotfix/role_check.py | 7 ++++--- 1 file 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()")