mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
14132 Add EventRule - change webhook and add in script processing to events (#14267)
--------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
from contextlib import contextmanager
|
||||
|
||||
from netbox.context import current_request, webhooks_queue
|
||||
from .webhooks import flush_webhooks
|
||||
from netbox.context import current_request, events_queue
|
||||
from .events import flush_events
|
||||
|
||||
|
||||
@contextmanager
|
||||
def change_logging(request):
|
||||
def event_tracking(request):
|
||||
"""
|
||||
Enable change logging by connecting the appropriate signals to their receivers before code is run, and
|
||||
disconnecting them afterward.
|
||||
Queue interesting events in memory while processing a request, then flush that queue for processing by the
|
||||
events pipline before returning the response.
|
||||
|
||||
:param request: WSGIRequest object with a unique `id` set
|
||||
"""
|
||||
current_request.set(request)
|
||||
webhooks_queue.set([])
|
||||
events_queue.set([])
|
||||
|
||||
yield
|
||||
|
||||
# Flush queued webhooks to RQ
|
||||
flush_webhooks(webhooks_queue.get())
|
||||
flush_events(events_queue.get())
|
||||
|
||||
# Clear context vars
|
||||
current_request.set(None)
|
||||
webhooks_queue.set([])
|
||||
events_queue.set([])
|
||||
|
Reference in New Issue
Block a user