from django.contrib.auth.models import User
from django.db import models

from notifications.enums import NotificationType, NotificationImportance


class Notification(models.Model):
    text = models.CharField(max_length=255, blank=True, help_text='Example: "Asset with ip 1.1.1.1 was created"')
    is_read = models.BooleanField(default=False)
    type = models.CharField(choices=NotificationType.choices, default=NotificationType.OTHER, max_length=8)
    importance = models.CharField(choices=NotificationImportance.choices,
                                  default=NotificationImportance.MEDIUM,
                                  max_length=6)
    created_at = models.DateTimeField(auto_now_add=True)
    recipient = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
