audit: fix model information being saved nested
This commit is contained in:
parent
4eaa46e717
commit
464b2cce88
|
@ -66,9 +66,7 @@ class AuditMiddleware:
|
||||||
return
|
return
|
||||||
|
|
||||||
action = EventAction.MODEL_CREATED if created else EventAction.MODEL_UPDATED
|
action = EventAction.MODEL_CREATED if created else EventAction.MODEL_UPDATED
|
||||||
EventNewThread(
|
EventNewThread(action, request, user=user, model=model_to_dict(instance)).run()
|
||||||
action, request, user=user, kwargs={"model": model_to_dict(instance)}
|
|
||||||
).run()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
|
@ -83,5 +81,5 @@ class AuditMiddleware:
|
||||||
EventAction.MODEL_DELETED,
|
EventAction.MODEL_DELETED,
|
||||||
request,
|
request,
|
||||||
user=user,
|
user=user,
|
||||||
kwargs={"model": model_to_dict(instance)},
|
model=model_to_dict(instance),
|
||||||
).run()
|
).run()
|
||||||
|
|
|
@ -25,10 +25,13 @@ class EventNewThread(Thread):
|
||||||
kwargs: Dict[str, Any]
|
kwargs: Dict[str, Any]
|
||||||
user: Optional[User] = None
|
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__()
|
super().__init__()
|
||||||
self.action = action
|
self.action = action
|
||||||
self.request = request
|
self.request = request
|
||||||
|
self.user = user
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
Reference in New Issue