Fixes #2284: Record object deletions before the request finishes

This commit is contained in:
Jeremy Stretch
2018-07-30 16:33:37 -04:00
parent 722d0d5554
commit 249c3d0e81
2 changed files with 44 additions and 28 deletions

View File

@@ -1,11 +1,13 @@
import datetime
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.db.models import Q
from extras.models import Webhook
from extras.constants import OBJECTCHANGE_ACTION_CREATE, OBJECTCHANGE_ACTION_DELETE, OBJECTCHANGE_ACTION_UPDATE
from utilities.api import get_serializer_for_model
from .constants import WEBHOOK_MODELS
def enqueue_webhooks(instance, action):
@@ -13,6 +15,9 @@ def enqueue_webhooks(instance, action):
Find Webhook(s) assigned to this instance + action and enqueue them
to be processed
"""
if not settings.WEBHOOKS_ENABLED or instance._meta.model_name not in WEBHOOK_MODELS:
return
type_create = action == OBJECTCHANGE_ACTION_CREATE
type_update = action == OBJECTCHANGE_ACTION_UPDATE
type_delete = action == OBJECTCHANGE_ACTION_DELETE