39 lines
1.6 KiB
Python
39 lines
1.6 KiB
Python
from django.db import models
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
#from aitrainer_backoffice.models.notification import Notification
|
|
from ..models import Customer
|
|
|
|
class Notification(models.Model):
|
|
notification_id = models.AutoField(primary_key=True)
|
|
message_title = models.CharField(max_length=50)
|
|
message_body = models.TextField(max_length=100, blank=True, null=True)
|
|
image_url = models.ImageField(upload_to='images/', help_text='The notification image')
|
|
schedule_date = models.DateField(blank=True, null=True)
|
|
schedule_hook = models.TextField(max_length=100, blank=True, null=True)
|
|
schedule_sql = models.TextField(max_length=1000, blank=True, null=True)
|
|
internal_name = models.CharField(max_length=50, blank=True, null=True)
|
|
internal_description = models.TextField(max_length=500, blank=True, null=True)
|
|
active = models.BooleanField(default=0)
|
|
|
|
class Meta:
|
|
db_table = 'notification'
|
|
verbose_name = _("Notification")
|
|
verbose_name_plural = _("Notifications")
|
|
|
|
def __str__(self):
|
|
return self.internal_name
|
|
|
|
class NotificationHistory(models.Model):
|
|
notification_history_id = models.AutoField(primary_key=True)
|
|
notification = models.ForeignKey(Notification, on_delete=models.CASCADE)
|
|
customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
|
|
response = models.CharField(max_length=255)
|
|
notification_date = models.DateTimeField(blank=True, null=True)
|
|
|
|
class Meta:
|
|
db_table = 'notification_history'
|
|
app_label = 'controlling'
|
|
|
|
def __str__(self):
|
|
return f'{self.notification};{self.customer};{self.response}' |