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' %} -
  • - - - Availability - -
  • -
  • - - - Team Notes - -
  • -
  • - - - Personal Notes - -
  • - {% endif %} +
  • + + + Availability + +
  • +
  • + + + Notes + +
  • + {% endif %}
  • diff --git a/templates/pages/add_note_from_tryout.html b/templates/pages/add_note_from_tryout.html index 6591e6b..89bd793 100644 --- a/templates/pages/add_note_from_tryout.html +++ b/templates/pages/add_note_from_tryout.html @@ -13,14 +13,14 @@
    -
    diff --git a/templates/pages/notes.html b/templates/pages/notes.html new file mode 100644 index 0000000..c9d9c49 --- /dev/null +++ b/templates/pages/notes.html @@ -0,0 +1,172 @@ +{% extends "layouts/base.html" %} +{% block title %}Notes - TryoutPro{% endblock %} +{% block page_title %}Notes{% endblock %} +{% block breadcrumb %}Home / Notes{% endblock %} + +{% block content %} +
    + + {% if org_team %} +
    +
    +

    Team Notes

    + {{ org_team.name }} +
    +
    +
    + + +
    + + +

    These notes will be visible to all players on your team.

    +
    + +
    + +
    +
    +
    +
    + {% endif %} + + +
    +
    +

    Add Personal Note

    + {% if org_team %} + {{ org_team.name }} + {% endif %} +
    +
    +
    + + +
    + + +
    + +
    + + +

    These notes will only be visible to the selected player.

    +
    + +
    + +

    Link this note to a specific match, tryout, or team for better organization.

    + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    + + {% if org_team and team_notes %} +
    +
    +

    Team Notes History

    +
    +
    + + + + + + + + + {% for note in team_notes %} + + + + + {% endfor %} + +
    Last UpdatedContent Preview
    {{ note.updated_at.strftime('%B %d, %Y at %I:%M %p') if note.updated_at else 'Unknown date' }}{{ note.content[:100] if note.content else '' }}{% if note.content and note.content|length > 100 %}...{% endif %}
    +
    +
    + {% endif %} + + + {% if personal_notes %} +
    +
    +

    Recent Personal Notes

    +
    +
    +
    + {% for note in personal_notes %} +
    + + {{ note.player.full_name if note.player else 'Unknown Player' }} - + {{ note.created_at.strftime('%B %d, %Y') if note.created_at else 'Unknown date' }} + + {{ note.content | nl2br if note.content else '' }} + From: {{ note.coach.full_name if note.coach else 'Unknown Coach' }} + {% if note.match_id or note.team_id or note.tryout_id %} +
    + {% if note.match_id and note.match %} + {{ note.match.title }} + {% endif %} + {% if note.team_id and note.team %} + {{ note.team.name }} + {% endif %} + {% if note.tryout_id and note.tryout %} + {{ note.tryout.title }} + {% endif %} +
    + {% endif %} +
    + {% endfor %} +
    +
    +
    + {% endif %} +
    +{% endblock %} \ No newline at end of file diff --git a/templates/pages/teams.html b/templates/pages/teams.html index 3140b16..7bb67c7 100644 --- a/templates/pages/teams.html +++ b/templates/pages/teams.html @@ -66,6 +66,11 @@ {% endif %} + {% if current_user.role == 'coach' and team.coach_id == current_user.id %} + + Notes + + {% endif %}
    diff --git a/templates/pages/view_tryout.html b/templates/pages/view_tryout.html index 9f0b80f..4ca00c4 100644 --- a/templates/pages/view_tryout.html +++ b/templates/pages/view_tryout.html @@ -155,11 +155,14 @@ Pending {% endif %} - - - {% if player_eval_status.get(p.id) %}Edit{% else %}Evaluate{% endif %} - - + + + {% if player_eval_status.get(p.id) %}Edit{% else %}Evaluate{% endif %} + + + + + {% endif %} {% else %}