Browse Source

corrige código para erros apontados no travis no ultimo commit

pull/3298/head
Leandro Roberto 5 years ago
parent
commit
72db27eef0
  1. 21
      sapl/base/receivers.py

21
sapl/base/receivers.py

@ -49,10 +49,17 @@ def status_tramitacao_materia(sender, instance, **kwargs):
def audit_log_function(sender, **kwargs): def audit_log_function(sender, **kwargs):
if not sender or \
hasattr(sender, '_meta') and not sender._meta or \ try:
hasattr(sender._meta, 'app_config') and not sender._meta.app_config or \ if not sender._meta.app_config.name.startswith('sapl'):
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 return
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -64,15 +71,15 @@ def audit_log_function(sender, **kwargs):
return return
r = i.frame.f_locals.get('request', None) r = i.frame.f_locals.get('request', None)
try: try:
if r and \ if r.user._meta.label == settings.AUTH_USER_MODEL:
r.user._meta.label == settings.AUTH_USER_MODEL:
u = r.user u = r.user
break break
except: except:
# não é necessário usar logger, aqui é usada apenas para
# eliminar um o if complexo
pass pass
try: try:
instance = kwargs.get('instance')
operation = kwargs.get('operation') operation = kwargs.get('operation')
user = u user = u
model_name = instance.__class__.__name__ model_name = instance.__class__.__name__

Loading…
Cancel
Save