|
|
@ -1,5 +1,7 @@ |
|
|
|
|
|
|
|
from sqlalchemy.ext.associationproxy import association_proxy |
|
|
|
|
|
|
|
|
|
|
|
from app import db |
|
|
|
from app import db |
|
|
|
from app.models import Role |
|
|
|
from app.models import Role, NotificationPlayer |
|
|
|
|
|
|
|
|
|
|
|
class GamePlayer(db.Model): |
|
|
|
class GamePlayer(db.Model): |
|
|
|
__tablename__ = 'game_player' |
|
|
|
__tablename__ = 'game_player' |
|
|
@ -9,3 +11,10 @@ class GamePlayer(db.Model): |
|
|
|
role = db.Column(db.Enum(Role), server_default=Role(0).name, nullable=False) |
|
|
|
role = db.Column(db.Enum(Role), server_default=Role(0).name, nullable=False) |
|
|
|
game = db.relationship('Game', back_populates='game_players') |
|
|
|
game = db.relationship('Game', back_populates='game_players') |
|
|
|
user = db.relationship('User', back_populates='user_games') |
|
|
|
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)) |
|
|
|