1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-22 23:42:25 +00:00

Add logs in tox settings

This commit is contained in:
Yohann D'ANELLO 2020-03-11 17:20:16 +01:00
parent 5d25f9830c
commit 695ef446ec
5 changed files with 12 additions and 10 deletions

View File

@ -16,4 +16,4 @@ class ChangelogSerializer(serializers.ModelSerializer):
model = Changelog
fields = '__all__'
# noinspection PyProtectedMember
read_only_fields = [f.name for f in model._meta.get_fields()] # Changelogs are read-only protected
read_only_fields = [f.name for f in model._meta.get_fields()] # Changelogs are read-only protected

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from django.apps import AppConfig
from django.db.models.signals import pre_save, post_save, post_delete
from django.utils.translation import gettext_lazy as _
@ -11,4 +12,7 @@ class LogsConfig(AppConfig):
def ready(self):
# noinspection PyUnresolvedReferences
import logs.signals
from . import signals
pre_save.connect(signals.pre_save_object)
post_save.connect(signals.save_object)
post_delete.connect(signals.delete_object)

View File

@ -3,6 +3,7 @@
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from threading import local

View File

@ -2,13 +2,13 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.contenttypes.models import ContentType
from django.db.models.signals import pre_save, post_save, post_delete
from django.dispatch import receiver
from rest_framework.renderers import JSONRenderer
from rest_framework.serializers import ModelSerializer
import getpass
from note.models import NoteUser, Alias
from .middlewares import get_current_authenticated_user, get_current_ip
from .models import Changelog
@ -23,15 +23,14 @@ EXCLUDED = [
'cas_server.user',
'cas_server.userattributes',
'contenttypes.contenttype',
'logs.changelog', # Never remove this line
'logs.changelog', # Never remove this line
'migrations.migration',
'note.note' # We only store the subclasses
'note.note' # We only store the subclasses
'note.transaction',
'sessions.session',
]
@receiver(pre_save)
def pre_save_object(sender, instance, **kwargs):
"""
Avant la sauvegarde d'un modèle, on récupère l'ancienne instance actuellement en base de données
@ -44,7 +43,6 @@ def pre_save_object(sender, instance, **kwargs):
instance._previous = None
@receiver(post_save)
def save_object(sender, instance, **kwargs):
"""
Dès qu'un modèle est sauvegardé, une entrée dans la table `Changelog` est ajouté dans la base de données
@ -102,7 +100,6 @@ def save_object(sender, instance, **kwargs):
).save()
@receiver(post_delete)
def delete_object(sender, instance, **kwargs):
"""
Dès qu'un modèle est supprimé, une entrée dans la table `Changelog` est ajouté dans la base de données

View File

@ -32,7 +32,7 @@ deps =
pep8-naming
pyflakes
commands =
flake8 apps/activity apps/api apps/member apps/note
flake8 apps/activity apps/api apps/logs apps/member apps/note
[flake8]
# Ignore too many errors, should be reduced in the future