ajustements des calendriers, ajout de matchs jouer vs joueur
This commit is contained in:
+27
-3
@@ -144,10 +144,22 @@ def view_tryout(tryout_id):
|
||||
|
||||
# Determine if current user can edit this tryout
|
||||
can_edit = current_user.can_manage_this_tryout(tryout)
|
||||
|
||||
|
||||
# Determine if current user can view the calendar (managers/coaches can always see it)
|
||||
# Players need to be registered or participating in a match
|
||||
can_view_calendar = can_edit
|
||||
if current_user.role == 'player':
|
||||
# Check if player is participating in any matches for this tryout
|
||||
player_in_match = MatchParticipant.query.join(Match).filter(
|
||||
MatchParticipant.player_id == current_user.id,
|
||||
Match.tryout_id == tryout_id
|
||||
).first() is not None
|
||||
|
||||
can_view_calendar = is_registered or player_in_match
|
||||
|
||||
# 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 = []
|
||||
@@ -155,7 +167,18 @@ def view_tryout(tryout_id):
|
||||
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'
|
||||
'team2': match.team2.name if match.team2 else 'TBD',
|
||||
'team1_players': [{'name': m.player.full_name, 'position': m.position} for m in match.team1.members.all()] if match.team1 else [],
|
||||
'team2_players': [{'name': m.player.full_name, 'position': m.position} for m in match.team2.members.all()] if match.team2 else []
|
||||
}
|
||||
elif match.match_type == 'player_vs_player':
|
||||
team1_players = [p.player.full_name for p in match.participants.filter_by(team_side=1).all()]
|
||||
team2_players = [p.player.full_name for p in match.participants.filter_by(team_side=2).all()]
|
||||
participants = {
|
||||
'team1': ', '.join(team1_players) if team1_players else 'TBD',
|
||||
'team2': ', '.join(team2_players) if team2_players else 'TBD',
|
||||
'team1_player_names': team1_players,
|
||||
'team2_player_names': team2_players
|
||||
}
|
||||
else:
|
||||
participants = [p.player.full_name for p in match.participants.all()]
|
||||
@@ -173,6 +196,7 @@ def view_tryout(tryout_id):
|
||||
registrations=registrations,
|
||||
team_data=team_data,
|
||||
can_edit=can_edit,
|
||||
can_view_calendar=can_view_calendar,
|
||||
all_players=all_players,
|
||||
matches=matches,
|
||||
match_data=match_data,
|
||||
|
||||
Reference in New Issue
Block a user