first structure & deployment of notification
This commit is contained in:
35
apps/notification/models.py
Normal file
35
apps/notification/models.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from apps.core.models import BaseModel
|
||||
from apps.authentication.models import Organization
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Notification(BaseModel):
|
||||
NOTIFICATION_TYPES = (
|
||||
('quota', 'Quota'),
|
||||
('inventory', 'Inventory'),
|
||||
('transaction', 'Transaction'),
|
||||
('system', 'System'),
|
||||
)
|
||||
|
||||
organization = models.ForeignKey(
|
||||
Organization,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='notifications',
|
||||
null=True
|
||||
)
|
||||
|
||||
title = models.CharField(max_length=255, null=True)
|
||||
message = models.TextField(null=True, blank=True)
|
||||
type = models.CharField(
|
||||
max_length=50,
|
||||
choices=NOTIFICATION_TYPES,
|
||||
default='system'
|
||||
)
|
||||
is_read = models.BooleanField(default=False)
|
||||
delivered = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.organization.name} - {self.title}'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
return super(Notification, self).save(*args, **kwargs)
|
||||
Reference in New Issue
Block a user