From 72db27eef0bd015cb421f0f98c6174976b44dc3b Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Wed, 14 Oct 2020 12:48:09 -0300 Subject: [PATCH] =?UTF-8?q?corrige=20c=C3=B3digo=20para=20erros=20apontado?= =?UTF-8?q?s=20no=20travis=20no=20ultimo=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/receivers.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sapl/base/receivers.py b/sapl/base/receivers.py index 57d7dbf13..41490c5c7 100644 --- a/sapl/base/receivers.py +++ b/sapl/base/receivers.py @@ -49,10 +49,17 @@ def status_tramitacao_materia(sender, instance, **kwargs): def audit_log_function(sender, **kwargs): - if not sender or \ - hasattr(sender, '_meta') and not sender._meta or \ - hasattr(sender._meta, 'app_config') and not sender._meta.app_config or \ - not sender._meta.app_config.name.startswith('sapl'): + + try: + if not sender._meta.app_config.name.startswith('sapl'): + return + except: + # não é necessário usar logger, aqui é usada apenas para + # eliminar um o if complexo + return + + instance = kwargs.get('instance') + if instance._meta.model == AuditLog: return logger = logging.getLogger(__name__) @@ -64,15 +71,15 @@ def audit_log_function(sender, **kwargs): return r = i.frame.f_locals.get('request', None) try: - if r and \ - r.user._meta.label == settings.AUTH_USER_MODEL: + if r.user._meta.label == settings.AUTH_USER_MODEL: u = r.user break except: + # não é necessário usar logger, aqui é usada apenas para + # eliminar um o if complexo pass try: - instance = kwargs.get('instance') operation = kwargs.get('operation') user = u model_name = instance.__class__.__name__