From fad7fd731cac1db7bbcabd3903bebefcc95b555b Mon Sep 17 00:00:00 2001 From: John Anderson Date: Sat, 21 Jul 2018 18:08:10 -0400 Subject: [PATCH] fix type_delete webhooks after refactor --- netbox/extras/middleware.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/netbox/extras/middleware.py b/netbox/extras/middleware.py index e92f5692e..8e15d1ce9 100644 --- a/netbox/extras/middleware.py +++ b/netbox/extras/middleware.py @@ -62,14 +62,13 @@ class ChangeLoggingAndWebhookMiddleware(object): # Perform change logging and fire Webhook signals for obj, action in _thread_locals.changed_objects: - if obj.pk: - # Log object changes - if hasattr(obj, 'log_change'): - obj.log_change(request.user, request.id, action) + # Log object changes + if obj.pk and hasattr(obj, 'log_change'): + obj.log_change(request.user, request.id, action) - # Enqueue Webhooks if they are enabled - if settings.WEBHOOKS_ENABLED and obj.__class__._meta.verbose_name in WEBHOOK_MODELS: - enqueue_webhooks(obj, action) + # Enqueue Webhooks if they are enabled + if settings.WEBHOOKS_ENABLED and obj.__class__._meta.verbose_name in WEBHOOK_MODELS: + enqueue_webhooks(obj, action) # Housekeeping: 1% chance of clearing out expired ObjectChanges if _thread_locals.changed_objects and settings.CHANGELOG_RETENTION and random.randint(1, 100) == 1: