Files
n3wt-school/Back-End/GestionNotification/models.py
Luc SORIGNET af0cd1c840 chore: Initial Commit
feat: Gestion des inscriptions [#1]
feat(frontend): Création des vues pour le paramétrage de l'école [#2]
feat: Gestion du login [#6]
fix: Correction lors de la migration des modèle [#8]
feat: Révision du menu principal [#9]
feat: Ajout d'un footer [#10]
feat: Création des dockers compose pour les environnements de
développement et de production [#12]
doc(ci): Mise en place de Husky et d'un suivi de version automatique [#14]
2024-11-18 16:06:21 +01:00

28 lines
1.0 KiB
Python

from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils.translation import gettext_lazy as _
from django.conf import settings
from GestionLogin.models import Profil
class TypeNotif(models.IntegerChoices):
NOTIF_NONE = 0, _('Aucune notification')
NOTIF_MESSAGE = 1, _('Un message a été reçu')
NOTIF_DI = 2, _('Le dossier d\'inscription a été mis à jour')
class Notification(models.Model):
user = models.ForeignKey(Profil, on_delete=models.PROTECT)
message = models.CharField(max_length=255)
is_read = models.BooleanField(default=False)
created_at = models.DateTimeField(auto_now_add=True)
typeNotification = models.IntegerField(choices=TypeNotif, default=0)
@property
def typeNotification_label(self):
return self.get_typeNotification_display()
def get_typeNotification_display(self):
return TypeNotif(self.typeNotification).label
def __str__(self):
return f'Notification for {self.user.username}'