forked from devs/PCv5
24 lines
774 B
Python
24 lines
774 B
Python
from app import db
|
|
from datetime import datetime
|
|
|
|
class Notification(db.Model):
|
|
""" A long-term `flash` notification. It is deleted when watched """
|
|
__tablename__ = 'notification'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
text = db.Column(db.UnicodeText)
|
|
href = db.Column(db.UnicodeText)
|
|
date = db.Column(db.DateTime, default=datetime.now())
|
|
|
|
owner_id = db.Column(db.Integer, db.ForeignKey('member.id'), nullable=False)
|
|
|
|
def __init__(self, owner_id, text, href=None):
|
|
""" Check weather or not the id is valid before creating the notif! """
|
|
self.text = text
|
|
self.href = href
|
|
self.owner_id = owner_id
|
|
|
|
def __repr__(self):
|
|
return f'<Notification to {self.owner.name}: {self.text} ({self.href})>'
|