ajout d'un calendrier pour sceduler des match

This commit is contained in:
cedrick2711
2026-07-14 13:35:30 -04:00
parent acb9bc3256
commit 83ee10ca64
15 changed files with 968 additions and 6 deletions
+46 -1
View File
@@ -60,10 +60,13 @@ class User(UserMixin, db.Model):
return self.role == 'president'
def can_manage_tryouts(self):
return self.role in ['president', 'manager']
return self.role in ['president', 'manager', 'coach', 'scout']
def can_manage_teams(self):
return self.role in ['president', 'manager']
def can_schedule_matches(self):
return self.role in ['president', 'manager', 'coach']
def can_manage_this_tryout(self, tryout):
"""Check if user can manage a specific tryout (president, or manager/coach in charge of it)."""
@@ -181,3 +184,45 @@ class TeamMember(db.Model):
added_at = db.Column(db.DateTime, default=datetime.utcnow)
player = db.relationship('User', overlaps="player_ref,team_assignments") # Many-to-one, no dynamic loader
class Match(db.Model):
"""Matches/scrimmages scheduled within tryouts."""
__tablename__ = 'matches'
id = db.Column(db.Integer, primary_key=True)
tryout_id = db.Column(db.Integer, db.ForeignKey('tryouts.id'), nullable=False)
title = db.Column(db.String(200), nullable=False)
description = db.Column(db.Text, nullable=True)
date = db.Column(db.Date, nullable=False)
start_time = db.Column(db.Time, nullable=True)
end_time = db.Column(db.Time, nullable=True)
location = db.Column(db.String(200), nullable=True)
status = db.Column(db.String(20), default='scheduled') # scheduled, completed, cancelled
match_type = db.Column(db.String(20), nullable=False) # team_vs_team, player_scrim
created_by = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
# For team vs team matches
team1_id = db.Column(db.Integer, db.ForeignKey('teams.id'), nullable=True)
team2_id = db.Column(db.Integer, db.ForeignKey('teams.id'), nullable=True)
creator = db.relationship('User', backref='created_matches')
tryout = db.relationship('Tryout', backref='matches')
team1 = db.relationship('Team', foreign_keys=[team1_id], backref='matches_as_team1')
team2 = db.relationship('Team', foreign_keys=[team2_id], backref='matches_as_team2')
participants = db.relationship('MatchParticipant', backref='match', lazy='dynamic')
def get_participating_players(self):
"""Return list of players participating in this match."""
return [p.player_id for p in self.participants.all()]
class MatchParticipant(db.Model):
"""Players participating in player scrimmage matches."""
__tablename__ = 'match_participants'
id = db.Column(db.Integer, primary_key=True)
match_id = db.Column(db.Integer, db.ForeignKey('matches.id'), nullable=False)
player_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
added_at = db.Column(db.DateTime, default=datetime.utcnow)
player = db.relationship('User')