You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
897 B
20 lines
897 B
from sqlalchemy.ext.associationproxy import association_proxy |
|
from sqlalchemy.sql import func |
|
|
|
from app import db |
|
from app.models import NotificationPlayer |
|
|
|
class Notification(db.Model): |
|
__tablename__ = 'notification' |
|
id = db.Column(db.Integer, primary_key=True) |
|
game_id = db.Column(db.Integer, db.ForeignKey('game.id'), nullable=False) |
|
message = db.Column(db.Text, nullable=False) |
|
type = db.Column(db.String(64), nullable=False, default='General') |
|
timestamp = db.Column(db.DateTime, server_default=func.now(), nullable=False) |
|
|
|
notification_recipients = db.relationship( |
|
'NotificationPlayer', |
|
back_populates='notification', |
|
cascade='save-update, merge, delete, delete-orphan') |
|
recipients = association_proxy('notification_recipients', 'player', |
|
creator=lambda player: NotificationPlayer(recipient=player))
|
|
|