ajout d'un calendrier pour sceduler des match
This commit is contained in:
+19
-1
@@ -1,7 +1,7 @@
|
||||
from flask import Blueprint, render_template, redirect, url_for, flash, request
|
||||
from flask_login import login_required, current_user
|
||||
from extensions import db
|
||||
from models import User, Tryout, TryoutRegistration, Evaluation, Team, TeamMember, OrgTeam
|
||||
from models import User, Tryout, TryoutRegistration, Evaluation, Team, TeamMember, OrgTeam, Match, MatchParticipant
|
||||
from datetime import datetime
|
||||
|
||||
tryouts_bp = Blueprint('tryouts', __name__, url_prefix='/tryouts')
|
||||
@@ -148,6 +148,22 @@ def view_tryout(tryout_id):
|
||||
# Get all players (for manager registration dropdown)
|
||||
all_players = User.query.filter_by(role='player').order_by(User.full_name).all()
|
||||
|
||||
# Get matches for this tryout with participant info
|
||||
matches = Match.query.filter_by(tryout_id=tryout_id).order_by(Match.date).all()
|
||||
match_data = []
|
||||
for match in matches:
|
||||
if match.match_type == 'team_vs_team':
|
||||
participants = {
|
||||
'team1': match.team1.name if match.team1 else 'TBD',
|
||||
'team2': match.team2.name if match.team2 else 'TBD'
|
||||
}
|
||||
else:
|
||||
participants = [p.player.full_name for p in match.participants.all()]
|
||||
match_data.append({
|
||||
'match': match,
|
||||
'participants': participants
|
||||
})
|
||||
|
||||
return render_template('pages/view_tryout.html',
|
||||
tryout=tryout,
|
||||
registered_players=registered_players,
|
||||
@@ -158,6 +174,8 @@ def view_tryout(tryout_id):
|
||||
team_data=team_data,
|
||||
can_edit=can_edit,
|
||||
all_players=all_players,
|
||||
matches=matches,
|
||||
match_data=match_data,
|
||||
now=datetime.utcnow())
|
||||
|
||||
@tryouts_bp.route('/<int:tryout_id>/register', methods=['POST'])
|
||||
|
||||
Reference in New Issue
Block a user