From aecd3fc86f3d0689d99798364f68c05983848663 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 27 Feb 2020 15:30:16 +0100 Subject: [PATCH] Update excluded models list --- apps/logs/signals.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/apps/logs/signals.py b/apps/logs/signals.py index 2d7f2711..7bef4f60 100644 --- a/apps/logs/signals.py +++ b/apps/logs/signals.py @@ -43,17 +43,25 @@ def get_user_and_ip(sender): EXCLUDED = [ - 'changelog', - 'migration', - 'revision', - 'session', - 'version', + 'admin.logentry', + 'authtoken.token', + 'cas_server.user', + 'cas_server.userattributes', + 'contenttypes.contenttype', + 'logs.changelog', + 'migrations.migration', + 'note.noteuser', + 'note.noteclub', + 'note.notespecial', + 'sessions.session', + 'reversion.revision', + 'reversion.version', ] @receiver(pre_save) def save_object(sender, instance, **kwargs): - model_name = sender.__name__ - if model_name.lower() in EXCLUDED: + # noinspection PyProtectedMember + if instance._meta.label_lower in EXCLUDED: return previous = sender.objects.filter(pk=instance.pk).all() @@ -74,8 +82,8 @@ def save_object(sender, instance, **kwargs): @receiver(pre_delete) def delete_object(sender, instance, **kwargs): - model_name = sender.__name__ - if model_name.lower() in EXCLUDED: + # noinspection PyProtectedMember + if instance._meta.label_lower in EXCLUDED: return user, ip = get_user_and_ip(sender)