2024-05-03 21:34:47 +00:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
from authentication.models import ExtendedUser
|
|
|
|
|
|
|
|
|
|
|
|
class MessageTemplate(models.Model):
|
|
|
|
name = models.CharField(max_length=255)
|
|
|
|
message = models.TextField()
|
|
|
|
created = models.DateTimeField(auto_now_add=True)
|
|
|
|
marked_confidential = models.BooleanField(default=False)
|
2024-05-22 17:56:23 +00:00
|
|
|
marked_required = models.BooleanField(default=False) # may not be deleted
|
2024-05-03 21:34:47 +00:00
|
|
|
|
2024-05-09 21:24:43 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
2024-05-03 21:34:47 +00:00
|
|
|
|
|
|
|
class UserNotificationChannel(models.Model):
|
|
|
|
user = models.ForeignKey(ExtendedUser, models.CASCADE)
|
|
|
|
channel_type = models.CharField(choices=[('telegram', 'telegram'), ('email', 'email')], max_length=255)
|
|
|
|
channel_target = models.CharField(max_length=255)
|
|
|
|
event_filter = models.CharField(max_length=255)
|
|
|
|
active = models.BooleanField(default=True)
|
|
|
|
created = models.DateTimeField(auto_now_add=True)
|
|
|
|
|
|
|
|
def validate_constraints(self, exclude=None): # TODO: email -> emailaddress, telegram -> chatid
|
|
|
|
return True
|
2024-05-09 21:24:43 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
2024-05-09 21:42:30 +00:00
|
|
|
return self.user.username + '(' + self.channel_type + ')'
|