mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-20 20:32:25 -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:
@@ -11,7 +11,7 @@ from django_rq import get_queue
|
||||
from core.events import *
|
||||
from netbox.config import get_config
|
||||
from netbox.constants import RQ_QUEUE_DEFAULT
|
||||
from netbox.registry import registry
|
||||
from netbox.models.features import has_feature
|
||||
from users.models import User
|
||||
from utilities.api import get_serializer_for_model
|
||||
from utilities.rqworker import get_rq_retry
|
||||
@@ -55,11 +55,12 @@ def enqueue_event(queue, instance, user, request_id, event_type):
|
||||
Enqueue a serialized representation of a created/updated/deleted object for the processing of
|
||||
events once the request has completed.
|
||||
"""
|
||||
# Determine whether this type of object supports event rules
|
||||
# Bail if this type of object does not support event rules
|
||||
if not has_feature(instance, 'event_rules'):
|
||||
return
|
||||
|
||||
app_label = instance._meta.app_label
|
||||
model_name = instance._meta.model_name
|
||||
if model_name not in registry['model_features']['event_rules'].get(app_label, []):
|
||||
return
|
||||
|
||||
assert instance.pk is not None
|
||||
key = f'{app_label}.{model_name}:{instance.pk}'
|
||||
|
||||
Reference in New Issue
Block a user