From 464b2cce8868de303efacdb819f71b99ac53f2e6 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 21 Sep 2020 22:34:03 +0200 Subject: [PATCH] audit: fix model information being saved nested --- passbook/audit/middleware.py | 6 ++---- passbook/audit/signals.py | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/passbook/audit/middleware.py b/passbook/audit/middleware.py index a6e8ce9fb..769591267 100644 --- a/passbook/audit/middleware.py +++ b/passbook/audit/middleware.py @@ -66,9 +66,7 @@ class AuditMiddleware: return action = EventAction.MODEL_CREATED if created else EventAction.MODEL_UPDATED - EventNewThread( - action, request, user=user, kwargs={"model": model_to_dict(instance)} - ).run() + EventNewThread(action, request, user=user, model=model_to_dict(instance)).run() @staticmethod # pylint: disable=unused-argument @@ -83,5 +81,5 @@ class AuditMiddleware: EventAction.MODEL_DELETED, request, user=user, - kwargs={"model": model_to_dict(instance)}, + model=model_to_dict(instance), ).run() diff --git a/passbook/audit/signals.py b/passbook/audit/signals.py index 0e8da6a20..28199cc1a 100644 --- a/passbook/audit/signals.py +++ b/passbook/audit/signals.py @@ -25,10 +25,13 @@ class EventNewThread(Thread): kwargs: Dict[str, Any] user: Optional[User] = None - def __init__(self, action: str, request: HttpRequest, **kwargs): + def __init__( + self, action: str, request: HttpRequest, user: Optional[User] = None, **kwargs + ): super().__init__() self.action = action self.request = request + self.user = user self.kwargs = kwargs def run(self):