2021-07-05 23:07:12 +02:00
|
|
|
from enum import IntEnum
|
|
|
|
|
2021-05-31 01:11:50 +02:00
|
|
|
from tortoise import fields
|
|
|
|
from tortoise.models import Model
|
|
|
|
|
2021-07-05 23:07:12 +02:00
|
|
|
|
|
|
|
class NotificationStatus(IntEnum):
|
2023-05-22 13:00:37 +02:00
|
|
|
FAILED = 0
|
|
|
|
COMPLETED = 1
|
2021-05-31 01:11:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Notification(Model):
|
|
|
|
id = fields.UUIDField(pk=True)
|
|
|
|
status = fields.IntEnumField(NotificationStatus)
|
|
|
|
|
|
|
|
message = fields.TextField()
|
|
|
|
|
2022-12-07 21:46:57 +01:00
|
|
|
target = fields.ForeignKeyField("models.Publisher", null=True, related_name=False,)
|
2021-05-31 01:11:50 +02:00
|
|
|
|
|
|
|
publication = fields.ForeignKeyField(
|
|
|
|
"models.Publication", related_name="notifications", null=True
|
|
|
|
)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f"[{self.status}] {self.message}"
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
table = "notification"
|