2021-04-21 16:47:18 +00:00
|
|
|
"""
|
|
|
|
This module defines the Notification database class.
|
|
|
|
"""
|
|
|
|
|
2021-05-07 17:46:14 +00:00
|
|
|
from ..base import ext
|
2021-04-21 16:47:18 +00:00
|
|
|
|
2021-05-07 17:46:14 +00:00
|
|
|
|
|
|
|
class Notification(ext.Model):
|
2021-04-21 16:47:18 +00:00
|
|
|
__tablename__ = "notification"
|
2021-05-07 17:46:14 +00:00
|
|
|
id = ext.Column(ext.Integer, primary_key=True)
|
|
|
|
ora = ext.Column(ext.DateTime, nullable=False)
|
2021-04-21 16:47:18 +00:00
|
|
|
# Foreign Key
|
2021-05-07 17:46:14 +00:00
|
|
|
alert_id = ext.Column(ext.Integer, ext.ForeignKey("alert.id"), nullable=False)
|
2021-04-21 16:47:18 +00:00
|
|
|
# Relationships
|
2021-05-07 17:46:14 +00:00
|
|
|
alert = ext.relationship("Alert", back_populates="notifications")
|
2021-05-07 17:15:14 +00:00
|
|
|
|
|
|
|
def to_json(self):
|
|
|
|
return {
|
|
|
|
"id": self.id,
|
|
|
|
"ora": self.ora.isoformat(),
|
|
|
|
"alert_id": self.alert_id
|
2021-05-07 17:51:03 +00:00
|
|
|
}
|