Ajout de fonctionnalités:

Ajout de notes personnels et de notes d'équipe avec historique.
Ajout de prise de rendez-vous avec un coach selon ses disponibilités
This commit is contained in:
cedrick2711
2026-07-16 20:34:56 -04:00
parent b02fe29e30
commit 24fcc9a048
24 changed files with 2625 additions and 264 deletions
+73 -2
View File
@@ -6,7 +6,7 @@ This module handles CRUD operations for organization teams and player assignment
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 OrgTeam, User
from models import OrgTeam, User, Team, TeamMember, PersonalNote, TeamNote, Tryout
teams_bp = Blueprint('teams', __name__, url_prefix='/teams')
@@ -220,4 +220,75 @@ def remove_player(team_id, player_id):
player.team_id = None
db.session.commit()
flash(f'{player.full_name} removed from {team.name}.', 'success')
return redirect(url_for('teams.list_teams'))
return redirect(url_for('teams.list_teams'))
# Note actions from team page
@teams_bp.route('/<int:team_id>/add-team-note', methods=['POST'])
@login_required
def add_team_note(team_id):
"""Add a team improvement note from the team page (for coaches).
Args:
team_id: The ID of the team to add notes for.
Returns:
Response: Redirect to teams list with status message.
"""
team = OrgTeam.query.get_or_404(team_id)
if current_user.role == 'coach' and team.coach_id != current_user.id:
flash('Only the coach of this team can add notes.', 'danger')
return redirect(url_for('teams.list_teams'))
content = request.form.get('content', '').strip()
if content:
note = TeamNote(
org_team_id=team_id,
coach_id=current_user.id,
content=content
)
db.session.add(note)
db.session.commit()
flash('Team notes added successfully!', 'success')
return redirect(url_for('teams.list_teams'))
@teams_bp.route('/<int:team_id>/add-player-note/<int:player_id>', methods=['POST'])
@login_required
def add_player_note(team_id, player_id):
"""Add a personal note for a player from the team page (for coaches).
Args:
team_id: The ID of the team.
player_id: The ID of the player to add note for.
Returns:
Response: Redirect to teams list with status message.
"""
team = OrgTeam.query.get_or_404(team_id)
if current_user.role == 'coach' and team.coach_id != current_user.id:
flash('Only the coach of this team can add notes.', 'danger')
return redirect(url_for('teams.list_teams'))
player = User.query.get_or_404(player_id)
if player.role != 'player':
flash('Can only add notes for players.', 'danger')
return redirect(url_for('teams.list_teams'))
content = request.form.get('content', '').strip()
if content:
note = PersonalNote(
player_id=player_id,
coach_id=current_user.id,
content=content
)
db.session.add(note)
db.session.commit()
flash(f'Note added for {player.full_name}!', 'success')
return redirect(url_for('teams.list_teams'))