mirror of
https://github.com/netbox-community/netbox.git
synced 2026-02-05 14:56:24 -06:00
* Convert ObjectType to a concrete child model of ContentType * Add public flag to ObjectType * Catch post_migrate signal to update ObjectTypes * Reference ObjectType records instead of registry for feature support * Automatically create ObjectTypes * Introduce has_feature() utility function * ObjectTypeManager should not inherit from ContentTypeManager * Misc cleanup * Don't populate ObjectTypes during migration * Don't automatically create ObjectTypes when a ContentType is created * Fix test * Extend has_feature() to accept a model or OT/CT * Misc cleanup * Deprecate get_for_id() on ObjectTypeManager * Rename contenttypes.py to object_types.py * Add index to features ArrayField * Keep FK & M2M fields pointing to ContentType * Add get_for_models() to ObjectTypeManager * Add tests for manager methods & utility functions * Fix migrations for M2M relations to ObjectType * model_is_public() should return False for non-core & non-plugin models * Order ObjectType by app_label & model name * Resolve migrations conflict
This commit is contained in:
@@ -20,6 +20,7 @@ from core.choices import JobStatusChoices
|
||||
from core.dataclasses import JobLogEntry
|
||||
from core.models import ObjectType
|
||||
from core.signals import job_end, job_start
|
||||
from netbox.models.features import has_feature
|
||||
from utilities.json import JobLogDecoder
|
||||
from utilities.querysets import RestrictedQuerySet
|
||||
from utilities.rqworker import get_queue_for_model
|
||||
@@ -148,7 +149,7 @@ class Job(models.Model):
|
||||
super().clean()
|
||||
|
||||
# Validate the assigned object type
|
||||
if self.object_type and self.object_type not in ObjectType.objects.with_feature('jobs'):
|
||||
if self.object_type and not has_feature(self.object_type, 'jobs'):
|
||||
raise ValidationError(
|
||||
_("Jobs cannot be assigned to this object type ({type}).").format(type=self.object_type)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user