mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-21 21:02:23 -06:00
#3892: Convert WEBHOOK_MODELS to a Q object
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import datetime
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from extras.models import Webhook
|
||||
@@ -14,7 +13,10 @@ def enqueue_webhooks(instance, user, request_id, action):
|
||||
Find Webhook(s) assigned to this instance + action and enqueue them
|
||||
to be processed
|
||||
"""
|
||||
if instance._meta.label.lower() not in WEBHOOK_MODELS:
|
||||
obj_type = ContentType.objects.get_for_model(instance.__class__)
|
||||
|
||||
webhook_models = ContentType.objects.filter(WEBHOOK_MODELS)
|
||||
if obj_type not in webhook_models:
|
||||
return
|
||||
|
||||
# Retrieve any applicable Webhooks
|
||||
@@ -23,7 +25,6 @@ def enqueue_webhooks(instance, user, request_id, action):
|
||||
ObjectChangeActionChoices.ACTION_UPDATE: 'type_update',
|
||||
ObjectChangeActionChoices.ACTION_DELETE: 'type_delete',
|
||||
}[action]
|
||||
obj_type = ContentType.objects.get_for_model(instance.__class__)
|
||||
webhooks = Webhook.objects.filter(obj_type=obj_type, enabled=True, **{action_flag: True})
|
||||
|
||||
if webhooks.exists():
|
||||
|
||||
Reference in New Issue
Block a user