mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 10:27:37 -02:30
Check for a broken ContentType -> model and log and skip
Apparently this has happened to a customer, per Nate Becker.
This commit is contained in:
@@ -13,6 +13,9 @@ orphaned_roles = []
|
|||||||
|
|
||||||
for ct in ContentType.objects.order_by('id'):
|
for ct in ContentType.objects.order_by('id'):
|
||||||
cls = ct.model_class()
|
cls = ct.model_class()
|
||||||
|
if cls is None:
|
||||||
|
sys.stderr.write(f"{ct!r} does not have a corresponding model class in the codebase. Skipping.\n")
|
||||||
|
continue
|
||||||
if not any(isinstance(f, ImplicitRoleField) for f in cls._meta.fields):
|
if not any(isinstance(f, ImplicitRoleField) for f in cls._meta.fields):
|
||||||
continue
|
continue
|
||||||
for obj in cls.objects.all():
|
for obj in cls.objects.all():
|
||||||
|
|||||||
Reference in New Issue
Block a user