mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
24 lines
898 B
Python
24 lines
898 B
Python
from django.db.models.signals import post_save
|
|
from django.dispatch import receiver
|
|
from .models import Notification, TypeNotif
|
|
from GestionMessagerie.models import Messagerie
|
|
from Subscriptions.models import RegistrationForm
|
|
|
|
@receiver(post_save, sender=Messagerie)
|
|
def notification_MESSAGE(sender, instance, created, **kwargs):
|
|
if created:
|
|
Notification.objects.create(
|
|
user=instance.destinataire,
|
|
message=(TypeNotif.NOTIF_MESSAGE).label,
|
|
typeNotification=TypeNotif.NOTIF_MESSAGE
|
|
)
|
|
|
|
@receiver(post_save, sender=RegistrationForm)
|
|
def notification_DI(sender, instance, created, **kwargs):
|
|
for responsable in instance.student.guardians.all():
|
|
Notification.objects.create(
|
|
user=responsable.associated_profile,
|
|
message=(TypeNotif.NOTIF_DI).label,
|
|
typeNotification=TypeNotif.NOTIF_DI
|
|
)
|