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 Auth.models import Profile

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(Profile, 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}'
    