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
979 B

from sqlalchemy.ext.associationproxy import association_proxy
from app import db
from app.models import Role, NotificationPlayer
class GamePlayer(db.Model):
__tablename__ = 'game_player'
id = db.Column(db.Integer, primary_key=True)
game_id = db.Column(db.Integer, db.ForeignKey('game.id'), primary_key=True, nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True, nullable=False)
role = db.Column(db.Enum(Role), server_default=Role(0).name, nullable=False)
game = db.relationship('Game', back_populates='game_players')
user = db.relationship('User', back_populates='user_games')
player_notifications = db.relationship(
'NotificationPlayer',
back_populates='recipient',
cascade='save-update, merge, delete, delete-orphan')
notifications = association_proxy('player_notifications', 'notification',
creator=lambda notification: NotificationPlayer(notification=notification))