changement de la gestion des équipes en ajouts de match (bugge)
This commit is contained in:
+11
-7
@@ -292,7 +292,9 @@ def create_match(tryout_id):
|
||||
return redirect(url_for('tryouts.view_tryout', tryout_id=tryout_id))
|
||||
|
||||
teams = Team.query.filter_by(tryout_id=tryout_id).all()
|
||||
all_players = User.query.filter_by(role='player').order_by(User.full_name).all()
|
||||
registrations = TryoutRegistration.query.filter_by(tryout_id=tryout_id).all()
|
||||
all_players = [User.query.get(r.player_id) for r in registrations if User.query.get(r.player_id)]
|
||||
all_players = sorted([p for p in all_players if p], key=lambda x: x.full_name)
|
||||
|
||||
if request.method == 'POST':
|
||||
title = request.form.get('title')
|
||||
@@ -353,13 +355,15 @@ def create_match(tryout_id):
|
||||
|
||||
# Handle player vs player matches
|
||||
elif match_type == 'player_vs_player':
|
||||
team1_player_ids = request.form.getlist('team1_player_ids')
|
||||
team2_player_ids = request.form.getlist('team2_player_ids')
|
||||
for pid in team1_player_ids:
|
||||
participant = MatchParticipant(match_id=match.id, player_id=int(pid), team_side=1)
|
||||
team1_player_ids = request.form.get('team1_player_ids', '')
|
||||
team2_player_ids = request.form.get('team2_player_ids', '')
|
||||
team1_ids = [int(p) for p in team1_player_ids.split(',') if p] if team1_player_ids else []
|
||||
team2_ids = [int(p) for p in team2_player_ids.split(',') if p] if team2_player_ids else []
|
||||
for pid in team1_ids:
|
||||
participant = MatchParticipant(match_id=match.id, player_id=pid, team_side=1)
|
||||
db.session.add(participant)
|
||||
for pid in team2_player_ids:
|
||||
participant = MatchParticipant(match_id=match.id, player_id=int(pid), team_side=2)
|
||||
for pid in team2_ids:
|
||||
participant = MatchParticipant(match_id=match.id, player_id=pid, team_side=2)
|
||||
db.session.add(participant)
|
||||
|
||||
# Handle player scrim matches
|
||||
|
||||
Reference in New Issue
Block a user