36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from django.db import models
|
|
from django_core.models.base import AbstractBaseModel
|
|
from django.utils.translation import gettext_lazy as _
|
|
from core.apps.accounts.choices import NotificationType
|
|
from django.contrib.auth import get_user_model
|
|
|
|
|
|
class Notification(AbstractBaseModel):
|
|
title = models.CharField(max_length=255, verbose_name=_("Title"))
|
|
description = models.TextField(verbose_name=_("Description"))
|
|
notification_type = models.CharField(max_length=255, choices=NotificationType, verbose_name=_("Type"))
|
|
long = models.FloatField(verbose_name=_("Long"))
|
|
lat = models.FloatField(verbose_name=_("Lat"))
|
|
|
|
def __str__(self):
|
|
return str(self.pk)
|
|
|
|
class Meta:
|
|
db_table = "notification"
|
|
verbose_name = _("Notification")
|
|
verbose_name_plural = _("Notifications")
|
|
|
|
|
|
class UserNotification(AbstractBaseModel):
|
|
user = models.ForeignKey(get_user_model(), verbose_name=_("User"), on_delete=models.CASCADE)
|
|
notification = models.ForeignKey(Notification, verbose_name=_("Notification"), on_delete=models.CASCADE)
|
|
is_read = models.BooleanField(verbose_name=_("Read"), default=False)
|
|
|
|
def __str__(self):
|
|
return str(self.pk)
|
|
|
|
class Meta:
|
|
db_table = "user_notification"
|
|
verbose_name = _("User Notification")
|
|
verbose_name_plural = _("User Notifications")
|