Ajout d'une catégorie jeux dans le tryouts, chacun des jeux offre des rôles différents pour les membres d'équipes. Remodelage du code un peu et ajout de docu
This commit is contained in:
+77
-21
@@ -1,4 +1,9 @@
|
||||
from flask import Blueprint, render_template, redirect, url_for, flash, request, jsonify
|
||||
"""Evaluation routes for assessing player performance during tryouts.
|
||||
|
||||
This module handles player evaluation creation, management, and viewing.
|
||||
"""
|
||||
|
||||
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, Evaluation, TryoutRegistration
|
||||
@@ -6,9 +11,19 @@ from sqlalchemy import func
|
||||
|
||||
evaluations_bp = Blueprint('evaluations', __name__, url_prefix='/evaluations')
|
||||
|
||||
|
||||
@evaluations_bp.route('')
|
||||
@login_required
|
||||
def list_evaluations():
|
||||
"""List all evaluations accessible to the current user.
|
||||
|
||||
President: All evaluations with player score summaries.
|
||||
Evaluators (coach/manager): Their given evaluations.
|
||||
Players: Their received evaluations.
|
||||
|
||||
Returns:
|
||||
Response: Rendered evaluations list template.
|
||||
"""
|
||||
user = current_user
|
||||
|
||||
if user.role == 'president':
|
||||
@@ -33,9 +48,22 @@ def list_evaluations():
|
||||
|
||||
return render_template('pages/evaluations.html', evaluations=evaluations, player_scores=player_scores)
|
||||
|
||||
|
||||
@evaluations_bp.route('/<int:tryout_id>/<int:player_id>', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def evaluate_player(tryout_id, player_id):
|
||||
"""Evaluate a specific player in a tryout.
|
||||
|
||||
GET: Render the evaluation form with any existing evaluation.
|
||||
POST: Create or update the evaluation for the player.
|
||||
|
||||
Args:
|
||||
tryout_id: The ID of the tryout.
|
||||
player_id: The ID of the player to evaluate.
|
||||
|
||||
Returns:
|
||||
Response: Evaluation form or redirect to tryout view.
|
||||
"""
|
||||
if not current_user.can_evaluate():
|
||||
flash('You do not have permission to evaluate players.', 'danger')
|
||||
return redirect(url_for('main.dashboard'))
|
||||
@@ -54,29 +82,41 @@ def evaluate_player(tryout_id, player_id):
|
||||
).first()
|
||||
|
||||
if request.method == 'POST':
|
||||
speed = request.form.get('speed_score')
|
||||
agility = request.form.get('agility_score')
|
||||
technique = request.form.get('technique_score')
|
||||
teamwork = request.form.get('teamwork_score')
|
||||
attitude = request.form.get('attitude_score')
|
||||
mecanics = request.form.get('mecanics_score')
|
||||
cohesion = request.form.get('cohesion_score')
|
||||
communication = request.form.get('communication_score')
|
||||
gamesense = request.form.get('gamesense_score')
|
||||
versatility = request.form.get('versatility_score')
|
||||
discipline = request.form.get('discipline_score')
|
||||
analysis = request.form.get('analysis_score')
|
||||
sport_ethics = request.form.get('sport_ethics_score')
|
||||
mental = request.form.get('mental_score')
|
||||
comments = request.form.get('comments')
|
||||
position = request.form.get('position_recommendation')
|
||||
|
||||
scores = []
|
||||
if speed: scores.append(int(speed))
|
||||
if agility: scores.append(int(agility))
|
||||
if technique: scores.append(int(technique))
|
||||
if teamwork: scores.append(int(teamwork))
|
||||
if attitude: scores.append(int(attitude))
|
||||
if mecanics: scores.append(int(mecanics))
|
||||
if cohesion: scores.append(int(cohesion))
|
||||
if communication: scores.append(int(communication))
|
||||
if gamesense: scores.append(int(gamesense))
|
||||
if versatility: scores.append(int(versatility))
|
||||
if discipline: scores.append(int(discipline))
|
||||
if analysis: scores.append(int(analysis))
|
||||
if sport_ethics: scores.append(int(sport_ethics))
|
||||
if mental: scores.append(int(mental))
|
||||
|
||||
overall = sum(scores) / len(scores) if scores else None
|
||||
|
||||
if existing_eval:
|
||||
existing_eval.speed_score = int(speed) if speed else None
|
||||
existing_eval.agility_score = int(agility) if agility else None
|
||||
existing_eval.technique_score = int(technique) if technique else None
|
||||
existing_eval.teamwork_score = int(teamwork) if teamwork else None
|
||||
existing_eval.attitude_score = int(attitude) if attitude else None
|
||||
existing_eval.mecanics_score = int(mecanics) if mecanics else None
|
||||
existing_eval.cohesion_score = int(cohesion) if cohesion else None
|
||||
existing_eval.communication_score = int(communication) if communication else None
|
||||
existing_eval.gamesense_score = int(gamesense) if gamesense else None
|
||||
existing_eval.versatility_score = int(versatility) if versatility else None
|
||||
existing_eval.discipline_score = int(discipline) if discipline else None
|
||||
existing_eval.analysis_score = int(analysis) if analysis else None
|
||||
existing_eval.sport_ethics_score = int(sport_ethics) if sport_ethics else None
|
||||
existing_eval.mental_score = int(mental) if mental else None
|
||||
existing_eval.overall_score = overall
|
||||
existing_eval.comments = comments
|
||||
existing_eval.position_recommendation = position
|
||||
@@ -86,11 +126,15 @@ def evaluate_player(tryout_id, player_id):
|
||||
tryout_id=tryout_id,
|
||||
player_id=player_id,
|
||||
evaluator_id=current_user.id,
|
||||
speed_score=int(speed) if speed else None,
|
||||
agility_score=int(agility) if agility else None,
|
||||
technique_score=int(technique) if technique else None,
|
||||
teamwork_score=int(teamwork) if teamwork else None,
|
||||
attitude_score=int(attitude) if attitude else None,
|
||||
mecanics_score=int(mecanics) if mecanics else None,
|
||||
cohesion_score=int(cohesion) if cohesion else None,
|
||||
communication_score=int(communication) if communication else None,
|
||||
gamesense_score=int(gamesense) if gamesense else None,
|
||||
versatility_score=int(versatility) if versatility else None,
|
||||
discipline_score=int(discipline) if discipline else None,
|
||||
analysis_score=int(analysis) if analysis else None,
|
||||
sport_ethics_score=int(sport_ethics) if sport_ethics else None,
|
||||
mental_score=int(mental) if mental else None,
|
||||
overall_score=overall,
|
||||
comments=comments,
|
||||
position_recommendation=position
|
||||
@@ -112,9 +156,21 @@ def evaluate_player(tryout_id, player_id):
|
||||
existing_eval=existing_eval,
|
||||
evaluators=evaluators)
|
||||
|
||||
|
||||
@evaluations_bp.route('/<int:tryout_id>/players')
|
||||
@login_required
|
||||
def players_to_evaluate(tryout_id):
|
||||
"""List players that need evaluation in a specific tryout.
|
||||
|
||||
Shows all registered players and marks which ones have already been evaluated
|
||||
by the current user.
|
||||
|
||||
Args:
|
||||
tryout_id: The ID of the tryout.
|
||||
|
||||
Returns:
|
||||
Response: Rendered players-to-evaluate template.
|
||||
"""
|
||||
if not current_user.can_evaluate():
|
||||
flash('Permission denied.', 'danger')
|
||||
return redirect(url_for('main.dashboard'))
|
||||
|
||||
Reference in New Issue
Block a user