Backend Draft
This commit is contained in:
24
backend/dashboard/models.py
Normal file
24
backend/dashboard/models.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from tenants.managers import TenantScopedManager
|
||||
from tenants.models import Tenant
|
||||
|
||||
class Notification(models.Model):
|
||||
tenant = models.ForeignKey(Tenant, on_delete=models.CASCADE, related_name='notifications')
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='notifications')
|
||||
title = models.CharField(max_length=255)
|
||||
message = models.TextField()
|
||||
is_read = models.BooleanField(default=False)
|
||||
link = models.URLField(max_length=500, null=True, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
objects = TenantScopedManager()
|
||||
|
||||
class Meta:
|
||||
ordering = ['-created_at']
|
||||
indexes = [
|
||||
models.Index(fields=['tenant', 'user', 'is_read']),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f"Notification for {self.user}: {self.title}"
|
||||
Reference in New Issue
Block a user