1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-12-13 23:05:16 +01:00

Implement signals

This commit is contained in:
Alexandre Iooss
2019-07-19 15:00:44 +02:00
parent d957e643c9
commit 085cd90a7f
5 changed files with 111 additions and 22 deletions

23
note/signals.py Normal file
View File

@@ -0,0 +1,23 @@
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2018-2019 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
def save_user_note(instance, created, **_kwargs):
"""
Hook to create and save a note when an user is updated
"""
if created:
from .models import NoteUser
NoteUser.objects.create(user=instance)
instance.note.save()
def save_club_note(instance, created, **_kwargs):
"""
Hook to create and save a note when a club is updated
"""
if created:
from .models import NoteClub
NoteClub.objects.create(club=instance)
instance.note.save()