From 16befc8848274a04e6a04aa5a7e631b7723df8e3 Mon Sep 17 00:00:00 2001 From: Zambom Date: Wed, 2 Nov 2016 22:45:09 -0300 Subject: [PATCH] Update log decorator [Issue: #231] --- core/decorators.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/decorators.py b/core/decorators.py index c2e439e..ad66922 100644 --- a/core/decorators.py +++ b/core/decorators.py @@ -1,8 +1,9 @@ from django.conf import settings +import json from functools import wraps from .models import Action, Resource, Action_Resource, Log, Notification -def log_decorator(log_action = '', log_resource = ''): +def log_decorator(log_component = '', log_action = '', log_resource = ''): def _log_decorator(view_function): @@ -10,7 +11,7 @@ def log_decorator(log_action = '', log_resource = ''): response = view_function(request, *args, **kwargs) - if request.user.is_authenticated and request.POST: + if request.user.is_authenticated: action = Action.objects.filter(name = log_action) resource = Resource.objects.filter(name = log_resource) @@ -36,6 +37,8 @@ def log_decorator(log_action = '', log_resource = ''): log = Log() log.user = request.user + log.component = log_component + log.context = json.dumps(request.log_context) log.action_resource = action_resource log.save() -- libgit2 0.21.2