nk20/apps/note/apps.py

42 lines
1.0 KiB
Python
Raw Permalink Normal View History

# Copyright (C) 2018-2021 by BDE ENS Paris-Saclay
2019-07-16 07:05:30 +00:00
# SPDX-License-Identifier: GPL-3.0-or-later
2019-07-08 12:30:58 +00:00
from django.apps import AppConfig
2019-07-19 13:00:44 +00:00
from django.conf import settings
from django.db.models.signals import pre_delete, pre_save, post_save
2019-07-16 07:05:30 +00:00
from django.utils.translation import gettext_lazy as _
2019-07-08 12:30:58 +00:00
2019-07-19 13:00:44 +00:00
from . import signals
2019-07-08 12:30:58 +00:00
class NoteConfig(AppConfig):
name = 'note'
2019-07-16 07:05:30 +00:00
verbose_name = _('note')
2019-07-19 13:00:44 +00:00
def ready(self):
"""
Define app internal signals to interact with other apps
"""
pre_save.connect(
signals.pre_save_note,
sender="note.noteuser",
)
pre_save.connect(
signals.pre_save_note,
sender="note.noteclub",
)
2019-07-19 13:00:44 +00:00
post_save.connect(
signals.save_user_note,
2020-02-18 11:31:15 +00:00
sender=settings.AUTH_USER_MODEL,
2019-07-19 13:00:44 +00:00
)
post_save.connect(
signals.save_club_note,
2020-02-18 11:31:15 +00:00
sender='member.Club',
2019-07-19 13:00:44 +00:00
)
pre_delete.connect(
signals.delete_transaction,
sender='note.transaction',
)