From 4097c19369473e8f0a3022a94321a3523f4958a2 Mon Sep 17 00:00:00 2001 From: tonytan4ever Date: Tue, 9 May 2017 22:22:06 -0400 Subject: [PATCH] Allow partial anonimous --- activity_log/middleware.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/activity_log/middleware.py b/activity_log/middleware.py index 65c351c..9195aba 100644 --- a/activity_log/middleware.py +++ b/activity_log/middleware.py @@ -36,8 +36,12 @@ def process_response(self, request, response): return response def _write_log(self, request, response, body): + user_exists_or_authenticated = ( + bool(getattr(request, 'user', None)) and + request.user.is_authenticated() + ) miss_log = [ - not(conf.ANONIMOUS or request.user.is_authenticated()), + not(conf.ANONIMOUS or user_exists_or_authenticated), request.method not in conf.METHODS, any(url in request.path for url in conf.EXCLUDE_URLS) ]