mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-04-25 01:04:46 +00:00
Merge pull request #74 from Isszul/master
implemented suggested fix in #72
This commit is contained in:
commit
0c8c189af5
1 changed files with 4 additions and 2 deletions
|
|
@ -42,7 +42,7 @@ class AuditlogMiddleware(MiddlewareMixin):
|
|||
|
||||
# Connect signal for automatic logging
|
||||
if hasattr(request, 'user') and hasattr(request.user, 'is_authenticated') and request.user.is_authenticated():
|
||||
set_actor = curry(self.set_actor, request.user)
|
||||
set_actor = curry(self.set_actor, user=request.user, signal_duid=threadlocal.auditlog['signal_duid'])
|
||||
pre_save.connect(set_actor, sender=LogEntry, dispatch_uid=threadlocal.auditlog['signal_duid'], weak=False)
|
||||
|
||||
def process_response(self, request, response):
|
||||
|
|
@ -64,11 +64,13 @@ class AuditlogMiddleware(MiddlewareMixin):
|
|||
return None
|
||||
|
||||
@staticmethod
|
||||
def set_actor(user, sender, instance, **kwargs):
|
||||
def set_actor(user, sender, instance, signal_duid, **kwargs):
|
||||
"""
|
||||
Signal receiver with an extra, required 'user' kwarg. This method becomes a real (valid) signal receiver when
|
||||
it is curried with the actor.
|
||||
"""
|
||||
if signal_duid != threadlocal.auditlog['signal_duid']:
|
||||
return
|
||||
try:
|
||||
app_label, model_name = settings.AUTH_USER_MODEL.split('.')
|
||||
auth_user_model = apps.get_model(app_label, model_name)
|
||||
|
|
|
|||
Loading…
Reference in a new issue