diff --git a/.agents/agents/test.agent.md b/.agents/agents/test.agent.md new file mode 100644 index 0000000..0832e0c --- /dev/null +++ b/.agents/agents/test.agent.md @@ -0,0 +1,10 @@ +--- +name: test +description: Describe what this custom agent does and when to use it. +argument-hint: The inputs this agent expects, e.g., "a task to implement" or "a question to answer". +# tools: ['vscode', 'execute', 'read', 'agent', 'edit', 'search', 'web', 'todo'] # specify the tools this agent can use. If not set, all enabled tools are allowed. +--- + + + +Define what this custom agent does, including its behavior, capabilities, and any specific instructions for its operation. \ No newline at end of file diff --git a/instance/team_tryouts.db b/instance/team_tryouts.db index bbc885b..9ab6cdd 100644 Binary files a/instance/team_tryouts.db and b/instance/team_tryouts.db differ diff --git a/routes/__pycache__/users.cpython-313.pyc b/routes/__pycache__/users.cpython-313.pyc index 5fd218c..cf78966 100644 Binary files a/routes/__pycache__/users.cpython-313.pyc and b/routes/__pycache__/users.cpython-313.pyc differ diff --git a/routes/users.py b/routes/users.py index 1bdeb0f..aec24ed 100644 --- a/routes/users.py +++ b/routes/users.py @@ -8,7 +8,7 @@ import os from flask import Blueprint, render_template, redirect, url_for, flash, request, jsonify, send_file from flask_login import login_required, current_user from extensions import db, hash_password -from models import User, ROLES, ESPORT_GAMES, PlayerDisponibility, UserGamertag, GAME_PLATFORMS, Contract, OrgTeam, CoachAvailability, TeamNote, PersonalNote, OneOnOneRequest, Match, Team, TeamMember, MatchParticipant, Tryout +from models import User, ROLES, ESPORT_GAMES, PlayerDisponibility, UserGamertag, GAME_PLATFORMS, Contract, OrgTeam, CoachAvailability, TeamNote, PersonalNote, OneOnOneRequest, Match, Team, TeamMember, MatchParticipant, Tryout, TryoutRegistration from werkzeug.utils import secure_filename from datetime import datetime, timedelta, date as date_type import requests @@ -1132,6 +1132,60 @@ def manage_personal_notes(): org_team=org_team) +@users_bp.route('/notes', methods=['GET']) +@login_required +def notes_dashboard(): + """Unified notes dashboard for coaches. + + GET: Render the combined notes management page with both team and personal notes forms. + + Returns: + Response: Rendered notes dashboard template. + """ + if current_user.role != 'coach': + flash('Only coaches can manage notes.', 'danger') + return redirect(url_for('main.dashboard')) + + # Get the coach's team + org_team = OrgTeam.query.filter_by(coach_id=current_user.id).first() + players = [] + if org_team: + players = User.query.filter_by(role='player', team_id=org_team.id).order_by(User.full_name).all() + + # Get existing team notes + team_notes = [] + latest_team_note = None + if org_team: + team_notes = TeamNote.query.filter_by(org_team_id=org_team.id).order_by(TeamNote.created_at.desc()).all() + latest_team_note = team_notes[0] if team_notes else None + + # Get all personal notes for players on this team + personal_notes = [] + if org_team: + personal_notes = PersonalNote.query.filter( + PersonalNote.player_id.in_([p.id for p in players]) + ).order_by(PersonalNote.created_at.desc()).all() + + # Get available matches and tryouts for context + matches = [] + tryouts = [] + teams = [] + if current_user.role == 'coach' and org_team: + tryouts = Tryout.query.filter_by(target_org_team_id=org_team.id).order_by(Tryout.date.desc()).all() + matches = Match.query.join(Tryout).filter(Tryout.target_org_team_id == org_team.id).order_by(Match.date.desc()).all() + teams = Team.query.order_by(Team.name).all() + + return render_template('pages/notes.html', + org_team=org_team, + players=players, + team_notes=team_notes, + latest_team_note=latest_team_note, + personal_notes=personal_notes, + matches=matches, + tryouts=tryouts, + teams=teams) + + # Note source types for filtering NOTE_SOURCE_MATCH = 'match' NOTE_SOURCE_TRYOUT = 'tryout' @@ -1256,7 +1310,7 @@ def add_personal_note(): db.session.add(note) db.session.commit() flash('Personal note added successfully!', 'success') - return redirect(url_for('users.my_notes')) + return redirect(url_for('users.notes_dashboard')) return render_template('pages/add_personal_note.html', players=players, @@ -1362,6 +1416,7 @@ def add_note_from_tryout(tryout_id): tryout = Tryout.query.get_or_404(tryout_id) # Check permissions + org_team = None if current_user.role == 'coach': org_team = OrgTeam.query.filter_by(coach_id=current_user.id).first() if not org_team or (tryout.target_org_team_id and tryout.target_org_team_id != org_team.id): @@ -1372,8 +1427,8 @@ def add_note_from_tryout(tryout_id): registrations = TryoutRegistration.query.filter_by(tryout_id=tryout_id).all() player_ids = [r.player_id for r in registrations] - # If coach, filter to only their team players - if current_user.role == 'coach' and org_team: + # If coach, filter to only their team players; otherwise include all + if org_team: players = User.query.filter(User.id.in_(player_ids), User.team_id == org_team.id).order_by(User.full_name).all() else: players = User.query.filter(User.id.in_(player_ids)).order_by(User.full_name).all() @@ -1403,7 +1458,11 @@ def add_note_from_tryout(tryout_id): flash('Personal note added successfully!', 'success') return redirect(url_for('tryouts.view_tryout', tryout_id=tryout_id)) + # Allow pre-selecting a player via query parameter + preselected_player_id = request.args.get('player_id', type=int) + return render_template('pages/add_note_from_tryout.html', tryout=tryout, players=players, - team_notes=team_notes) + team_notes=team_notes, + preselected_player_id=preselected_player_id) diff --git a/templates/layouts/base.html b/templates/layouts/base.html index f972f01..cfb94bb 100644 --- a/templates/layouts/base.html +++ b/templates/layouts/base.html @@ -88,25 +88,19 @@ {% endif %} {% if current_user.role == 'coach' %} -