From e64fc7dd88436690365ea2581221ec067e9d40b0 Mon Sep 17 00:00:00 2001 From: Felipe Bormann Date: Tue, 23 May 2017 21:33:05 -0300 Subject: [PATCH] modified logmixin to use attributes of class --- log/mixins.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/log/mixins.py b/log/mixins.py index 221b487..d587325 100644 --- a/log/mixins.py +++ b/log/mixins.py @@ -5,10 +5,10 @@ from .models import Log from users.models import User class LogMixin(object): - log_component = "" - log_context = {} - log_action = "" - log_resource = "" + log_component = None + log_context = None + log_action = None + log_resource = None def createLog(self, actor = None, component = '', log_action = '', log_resource = '', context = {}): if actor.is_authenticated: @@ -16,10 +16,23 @@ class LogMixin(object): log.user = str(actor) log.user_id = actor.id log.user_email = actor.email - log.context = context - log.component = component - log.action = log_action - log.resource = log_resource + if self.log_context is not None: + log.context = self.log_context + else: + log.context = context + if self.log_component is not None: + log.component = self.log_component + else: + log.component = component + + if self.log_action is not None: + log.action = self.log_action + else: + log.action = log_action + if self.log_resource is not None: + log.resource = self.log_resource + else: + log.resource = log_resource log.save() -- libgit2 0.21.2