mirror of
https://github.com/netbox-community/netbox.git
synced 2025-09-06 14:23:36 -06:00
Fixes #19988: has_feature() should gracefully handle invalid ContentTypes
This commit is contained in:
parent
4ce47e778b
commit
13db4f728c
@ -679,10 +679,14 @@ def has_feature(model_or_ct, feature):
|
|||||||
ot = model_or_ct
|
ot = model_or_ct
|
||||||
# If a ContentType was passed, resolve its model class
|
# If a ContentType was passed, resolve its model class
|
||||||
elif type(model_or_ct) is ContentType:
|
elif type(model_or_ct) is ContentType:
|
||||||
ot = ObjectType.objects.get_for_model(model_or_ct.model_class())
|
model_class = model_or_ct.model_class()
|
||||||
|
ot = ObjectType.objects.get_for_model(model_class) if model_class else None
|
||||||
# For anything else, look up the ObjectType
|
# For anything else, look up the ObjectType
|
||||||
else:
|
else:
|
||||||
ot = ObjectType.objects.get_for_model(model_or_ct)
|
ot = ObjectType.objects.get_for_model(model_or_ct)
|
||||||
|
# ObjectType is invalid/deleted
|
||||||
|
if ot is None:
|
||||||
|
return False
|
||||||
return feature in ot.features
|
return feature in ot.features
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user