1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-23 16:02:25 +00:00
nk20/apps/note/signals.py

31 lines
783 B
Python
Raw Normal View History

2020-02-18 20:30:26 +00:00
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
2019-07-19 13:00:44 +00:00
# SPDX-License-Identifier: GPL-3.0-or-later
2020-02-20 21:10:10 +00:00
def save_user_note(instance, created, raw, **_kwargs):
2019-07-19 13:00:44 +00:00
"""
Hook to create and save a note when an user is updated
"""
2020-02-20 21:10:10 +00:00
if raw:
# When provisionning data, do not try to autocreate
return
2019-07-19 13:00:44 +00:00
if created:
from .models import NoteUser
NoteUser.objects.create(user=instance)
instance.note.save()
2020-02-20 21:10:10 +00:00
def save_club_note(instance, created, raw, **_kwargs):
2019-07-19 13:00:44 +00:00
"""
Hook to create and save a note when a club is updated
"""
2020-02-20 21:10:10 +00:00
if raw:
# When provisionning data, do not try to autocreate
return
2019-07-19 13:00:44 +00:00
if created:
from .models import NoteClub
NoteClub.objects.create(club=instance)
instance.note.save()