mirror of https://gitlab.crans.org/bde/nk20
Add logs in tox settings
This commit is contained in:
parent
5d25f9830c
commit
695ef446ec
|
@ -2,6 +2,7 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from django.apps import AppConfig
|
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 _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,4 +12,7 @@ class LogsConfig(AppConfig):
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
# noinspection PyUnresolvedReferences
|
# 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)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
|
|
||||||
from threading import local
|
from threading import local
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
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.renderers import JSONRenderer
|
||||||
from rest_framework.serializers import ModelSerializer
|
from rest_framework.serializers import ModelSerializer
|
||||||
|
|
||||||
import getpass
|
import getpass
|
||||||
|
|
||||||
from note.models import NoteUser, Alias
|
from note.models import NoteUser, Alias
|
||||||
|
|
||||||
from .middlewares import get_current_authenticated_user, get_current_ip
|
from .middlewares import get_current_authenticated_user, get_current_ip
|
||||||
from .models import Changelog
|
from .models import Changelog
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ EXCLUDED = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@receiver(pre_save)
|
|
||||||
def pre_save_object(sender, instance, **kwargs):
|
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
|
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
|
instance._previous = None
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save)
|
|
||||||
def save_object(sender, instance, **kwargs):
|
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
|
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()
|
).save()
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_delete)
|
|
||||||
def delete_object(sender, instance, **kwargs):
|
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
|
Dès qu'un modèle est supprimé, une entrée dans la table `Changelog` est ajouté dans la base de données
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -32,7 +32,7 @@ deps =
|
||||||
pep8-naming
|
pep8-naming
|
||||||
pyflakes
|
pyflakes
|
||||||
commands =
|
commands =
|
||||||
flake8 apps/activity apps/api apps/member apps/note
|
flake8 apps/activity apps/api apps/logs apps/member apps/note
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# Ignore too many errors, should be reduced in the future
|
# Ignore too many errors, should be reduced in the future
|
||||||
|
|
Loading…
Reference in New Issue