ajout de match régulier pour les équipes et de pratiques

Ajout d'un profil public cliquable pour les utilisateurs
déplacement du profil
This commit is contained in:
cedrick2711
2026-07-28 12:39:53 -04:00
parent 69b6e217ae
commit b982cd0318
20 changed files with 2132 additions and 225 deletions
+19 -16
View File
@@ -53,12 +53,21 @@
</a>
</li>
{% endif %}
{% if current_user.role == 'player' %}
<li>
<a href="{{ url_for('teams.list_teams') }}" class="{% if request.endpoint and 'teams' in request.endpoint %}active{% endif %}">
<i class="fas fa-users-cog"></i>
<span>Teams</span>
<a href="{{ url_for('teams.my_teams') }}" class="{% if request.endpoint == 'teams.my_teams' %}active{% endif %}">
<i class="fas fa-users"></i>
<span>My Team(s)</span>
</a>
</li>
{% else %}
<li>
<a href="{{ url_for('teams.list_teams') }}" class="{% if request.endpoint and 'teams' in request.endpoint and request.endpoint != 'teams.my_teams' %}active{% endif %}">
<i class="fas fa-users-cog"></i>
<span>Manage Teams</span>
</a>
</li>
{% endif %}
{% if current_user.can_manage_users() %}
<li>
<a href="{{ url_for('users.list_users') }}" class="{% if request.endpoint and 'users' in request.endpoint and request.endpoint != 'users.profile' %}active{% endif %}">
@@ -67,19 +76,7 @@
</a>
</li>
{% endif %}
<li>
<a href="{{ url_for('users.profile') }}" class="{% if request.endpoint == 'users.profile' %}active{% endif %}">
<i class="fas fa-user"></i>
<span>My Profile</span>
</a>
</li>
{% if current_user.role == 'player' %}
<li>
<a href="{{ url_for('users.one_on_one') }}" class="{% if request.endpoint == 'users.one_on_one' %}active{% endif %}">
<i class="fas fa-calendar-check"></i>
<span>One on One</span>
</a>
</li>
<li>
<a href="{{ url_for('users.my_notes') }}" class="{% if request.endpoint == 'users.my_notes' %}active{% endif %}">
<i class="fas fa-sticky-note"></i>
@@ -97,7 +94,7 @@
<li>
<a href="{{ url_for('users.notes_dashboard') }}" class="{% if request.endpoint == 'users.notes_dashboard' or request.endpoint == 'users.manage_team_notes' or request.endpoint == 'users.manage_personal_notes' %}active{% endif %}">
<i class="fas fa-sticky-note"></i>
<span>Notes</span>
<span>Notes & One on One</span>
</a>
</li>
{% endif %}
@@ -108,6 +105,12 @@
</a>
</li>
<li class="nav-divider"></li>
<li>
<a href="{{ url_for('users.profile') }}" class="{% if request.endpoint == 'users.profile' %}active{% endif %}">
<i class="fas fa-user"></i>
<span>My Profile</span>
</a>
</li>
<li>
<a href="{{ url_for('auth.logout') }}" class="logout-link">
<i class="fas fa-sign-out-alt"></i>
+180 -1
View File
@@ -29,6 +29,61 @@
</div>
</div>
<!-- Create Event Modal (for clicking empty days) -->
<div id="createEventModal" class="modal hidden">
<div class="modal-backdrop" onclick="hideCreateEventModal()"></div>
<div class="modal-content">
<div class="modal-header">
<h3><i class="fas fa-plus-circle"></i> Create New Event</h3>
<button class="modal-close" onclick="hideCreateEventModal()">&times;</button>
</div>
<div class="modal-body">
<p class="mb-3"><strong>Date:</strong> <span id="createEventDate"></span></p>
<input type="hidden" id="createEventDateInput"/>
<div class="card mb-3">
<div class="card-body">
<h5><i class="fas fa-futbol"></i> Schedule Tryout Match</h5>
<p class="text-muted small">Add a scrim/match inside an existing tryout</p>
<div class="form-inline">
<select id="createTryoutSelect" class="form-select" style="flex:1;">
<option value="">-- Select a tryout --</option>
</select>
<button class="btn btn-sm btn-primary ml-2" onclick="goToTryoutMatch()">
<i class="fas fa-arrow-right"></i> Go
</button>
</div>
</div>
</div>
<div class="card mb-3">
<div class="card-body">
<h5><i class="fas fa-users"></i> Schedule Team Match</h5>
<p class="text-muted small">Regular season match for an org team</p>
<div class="form-inline">
<select id="createTeamSelect" class="form-select" style="flex:1;">
<option value="">-- Select a team --</option>
</select>
<button class="btn btn-sm btn-success ml-2" onclick="goToTeamMatch()">
<i class="fas fa-arrow-right"></i> Go
</button>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<h5><i class="fas fa-calendar-plus"></i> Create New Tryout</h5>
<p class="text-muted small">Create a brand new tryout event</p>
<button class="btn btn-sm btn-info" onclick="goToCreateTryout()">
<i class="fas fa-plus"></i> Create Tryout
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Event Details Modal -->
<div id="eventModal" class="modal hidden">
<div class="modal-backdrop" onclick="hideEventModal()"></div>
@@ -39,6 +94,9 @@
</div>
<div class="modal-body">
<div id="modalContent"></div>
<div id="modalPresenceToggle" class="form-actions mt-3" style="display: none; justify-content: center;">
<button class="btn btn-sm btn-outline" id="calPresenceBtn">Confirm</button>
</div>
<div id="modalActions" class="form-actions mt-3" style="display: none;">
<button class="btn btn-sm btn-danger" id="deleteMatchBtn" style="display: none;">
<i class="fas fa-trash"></i> Delete Match
@@ -74,13 +132,32 @@ document.addEventListener('DOMContentLoaded', function() {
eventClick: function(info) {
showEventModal(info.event);
},
dateClick: function(info) {
if (canScheduleMatches) {
var dateStr = info.dateStr;
showCreateEventModal(dateStr);
}
},
selectable: true,
select: function(info) {
if (canScheduleMatches) {
var dateStr = info.startStr;
showCreateEventModal(dateStr);
calendar.unselect();
}
},
slotMinTime: '12:00:00',
slotMaxTime: '24:00:00'
});
calendar.render();
// Store calendar in window for access
window.fcCalendar = calendar;
// Pre-load tryout and team options for the create modal
if (canScheduleMatches) {
fetchTryoutOptions();
fetchTeamOptions();
}
});
function changeView(viewName) {
@@ -89,6 +166,68 @@ function changeView(viewName) {
}
}
// --- Create Event Modal ---
function showCreateEventModal(dateStr) {
document.getElementById('createEventDate').textContent = dateStr;
document.getElementById('createEventDateInput').value = dateStr;
// Reset dropdowns
document.getElementById('createTryoutSelect').value = '';
document.getElementById('createTeamSelect').value = '';
document.getElementById('createEventModal').classList.remove('hidden');
}
function hideCreateEventModal() {
document.getElementById('createEventModal').classList.add('hidden');
}
function goToTryoutMatch() {
var tryoutId = document.getElementById('createTryoutSelect').value;
if (!tryoutId) { alert('Please select a tryout.'); return; }
var date = document.getElementById('createEventDateInput').value;
window.location.href = '/matches/create/' + tryoutId + '?date=' + date;
}
function goToTeamMatch() {
var teamId = document.getElementById('createTeamSelect').value;
if (!teamId) { alert('Please select a team.'); return; }
var date = document.getElementById('createEventDateInput').value;
window.location.href = '/team-matches/' + teamId + '/create?date=' + date;
}
function goToCreateTryout() {
// Tryout creation doesn't support pre-filling date easily, just navigate
window.location.href = '/tryouts/create';
}
// Pre-fetch data for dropdowns
function fetchTryoutOptions() {
fetch('/matches/api/manageable-tryouts')
.then(function(r) { return r.json(); })
.then(function(data) {
var sel = document.getElementById('createTryoutSelect');
sel.innerHTML = '<option value="">-- Select a tryout --</option>';
data.forEach(function(t) {
sel.innerHTML += '<option value="' + t.id + '">' + t.title + ' (' + t.date + ')</option>';
});
})
.catch(function() {});
}
function fetchTeamOptions() {
fetch('/team-matches/api/manageable-teams')
.then(function(r) { return r.json(); })
.then(function(data) {
var sel = document.getElementById('createTeamSelect');
sel.innerHTML = '<option value="">-- Select a team --</option>';
data.forEach(function(t) {
sel.innerHTML += '<option value="' + t.id + '">' + t.name + '</option>';
});
})
.catch(function() {});
}
function showEventModal(event) {
var props = event.extendedProps;
var title = event.title;
@@ -172,9 +311,49 @@ function showEventModal(event) {
document.getElementById('modalActions').style.display = 'none';
}
// Show presence toggle for matches where user is a participant
var presenceDiv = document.getElementById('modalPresenceToggle');
if (type === 'match' && props.user_participant_id) {
presenceDiv.style.display = 'flex';
var confirmed = props.user_attendance_confirmed || false;
var toggleBtn = document.getElementById('calPresenceBtn');
toggleBtn.textContent = confirmed ? '✅ Confirmed' : 'Confirm';
toggleBtn.className = 'btn btn-sm ' + (confirmed ? 'btn-success' : 'btn-outline');
toggleBtn.onclick = function() {
toggleCalendarPresence(props.match_id, props.user_participant_id, toggleBtn);
};
} else {
presenceDiv.style.display = 'none';
}
document.getElementById('eventModal').classList.remove('hidden');
}
function toggleCalendarPresence(matchId, participantId, btn) {
fetch('/matches/' + matchId + '/toggle-presence/' + participantId, {
method: 'POST',
headers: {
'X-CSRFToken': '{{ csrf_token() }}',
'Content-Type': 'application/json'
}
})
.then(function(r) { return r.json(); })
.then(function(data) {
if (data.attendance_confirmed) {
btn.classList.add('btn-success');
btn.classList.remove('btn-outline');
btn.textContent = '✅ Confirmed';
} else {
btn.classList.remove('btn-success');
btn.classList.add('btn-outline');
btn.textContent = 'Confirm';
}
})
.catch(function(err) {
console.error('Error toggling presence:', err);
});
}
function hideEventModal() {
document.getElementById('eventModal').classList.add('hidden');
}
+17 -3
View File
@@ -16,15 +16,19 @@
{% block content %}
<div class="card">
<div class="card-header">
<h3><i class="fas fa-futbol"></i> {% if match %}Edit Match{% else %}Schedule Match for {{ tryout.title }}{% endif %}</h3>
<h3><i class="fas fa-futbol"></i> {% if match %}Edit Match{% elif is_practice %}Schedule Practice — {{ team.name }}{% else %}Schedule Match for {{ tryout.title }}{% endif %}</h3>
{% if match %}
<p class="text-muted small">Match Type: <strong>{{ match.match_type.replace('_', ' ') | title }}</strong></p>
{% endif %}
</div>
<div class="card-body">
<form method="POST" action="{% if match %}{{ url_for('matches.edit_match', match_id=match.id) }}{% else %}{{ url_for('matches.create_match', tryout_id=tryout.id) }}{% endif %}" class="form" id="matchForm">
<form method="POST" action="{% if match %}{{ url_for('matches.edit_match', match_id=match.id) }}{% elif is_practice %}{{ url_for('team_matches.create_match', team_id=team_id) }}{% else %}{{ url_for('matches.create_match', tryout_id=tryout.id) }}{% endif %}" class="form" id="matchForm">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
{% if is_practice %}
<input type="hidden" name="title" value="Practice">
{% endif %}
{% if not is_practice %}
{% if not match %}
<div class="form-group">
<label for="match_type">Match Type</label>
@@ -37,16 +41,19 @@
{% else %}
<input type="hidden" name="match_type" value="{{ match.match_type }}">
{% endif %}
{% endif %}
{% if not is_practice %}
<div class="form-group">
<label for="title">Match Title</label>
<input type="text" name="title" id="title" class="form-input" value="{{ match.title if match else '' }}" placeholder="e.g., Alpha vs Bravo Scrimmage" required>
</div>
{% endif %}
<div class="form-row">
<div class="form-group">
<label for="date">Date</label>
<input type="date" name="date" id="date" class="form-input" value="{{ match.date.strftime('%Y-%m-%d') if match else tryout.date.strftime('%Y-%m-%d') }}" required>
<input type="date" name="date" id="date" class="form-input" value="{{ match.date.strftime('%Y-%m-%d') if match else (prefill_date if is_practice else tryout.date.strftime('%Y-%m-%d')) }}" required>
</div>
{% if match %}
<div class="form-group">
@@ -568,10 +575,17 @@ document.addEventListener('DOMContentLoaded', function() {
{% endif %}
{% if not match %}
{% if is_practice %}
// Practices default to player_scrim mode
document.getElementById('player-scrim-section').classList.remove('hidden');
document.getElementById('team-vs-team-section').classList.add('hidden');
document.getElementById('player-vs-player-section').classList.add('hidden');
{% else %}
toggleMatchType();
// Show all players initially
updatePlayerPool();
{% endif %}
{% endif %}
});
function allDisponibilitiesInitialized() {
+278
View File
@@ -0,0 +1,278 @@
{% extends "layouts/base.html" %}
{% block title %}My Team(s) - TryoutPro{% endblock %}
{% block page_title %}My Team(s){% endblock %}
{% block breadcrumb %}<span class="breadcrumb">Home / My Team(s)</span>{% endblock %}
{% block content %}
{% if team_data %}
{% for item in team_data %}
{% set team = item.team %}
<div class="card mb-4">
<div class="card-header">
<h3><i class="fas fa-users"></i> {{ team.name }}</h3>
</div>
<!-- Staff bar -->
<div class="team-staff-bar">
<div class="staff-row">
<div class="staff-group">
<span class="staff-label"><i class="fas fa-chalkboard-teacher"></i> Coaches</span>
<div class="staff-items">
{% if item.coaches %}
{% for c in item.coaches %}
<span class="staff-tag">{{ c.username }}</span>
{% endfor %}
{% else %}
<span class="text-muted text-sm">None</span>
{% endif %}
</div>
</div>
<div class="staff-group">
<span class="staff-label"><i class="fas fa-user-tie"></i> Managers</span>
<div class="staff-items">
{% if item.managers %}
{% for m in item.managers %}
<span class="staff-tag manager-tag">{{ m.username }}</span>
{% endfor %}
{% else %}
<span class="text-muted text-sm">None</span>
{% endif %}
</div>
</div>
</div>
</div>
<div class="card-body">
<!-- Team Roster -->
<h4 class="mb-3"><i class="fas fa-users"></i> Team Roster</h4>
{% set roster = team.get_players_with_status() %}
{% if roster %}
<div class="table-container mb-4">
<table class="table">
<thead>
<tr>
<th>Player</th>
<th>Status</th>
<th>Position</th>
</tr>
</thead>
<tbody>
{% for entry in roster %}
<tr>
<td>
<div class="user-mini">
<div class="avatar-sm">{{ entry.player.username[:2] | upper }}</div>
<a href="{{ url_for('users.view_user', user_id=entry.player.id) }}">{{ entry.player.username }}</a>
</div>
</td>
<td>
<span class="badge {% if entry.status == 'starter' %}badge-success{% else %}badge-warning{% endif %}">
{{ entry.status | capitalize }}
</span>
</td>
<td>{{ entry.position or '—' }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center py-3 text-muted">
<i class="fas fa-users-slash"></i> No players on this team.
</div>
{% endif %}
<!-- Team Matches -->
<h4 class="mb-3"><i class="fas fa-futbol"></i> Upcoming Matches</h4>
{% if item.matches %}
<div class="table-container">
<table class="table">
<thead>
<tr>
<th>Match</th>
<th>Opponent</th>
<th>Date</th>
<th>Time</th>
<th>Location</th>
<th>Presence</th>
<th>My Status</th>
</tr>
</thead>
<tbody>
{% for mdata in item.matches %}
{% set tm = mdata.match %}
<tr>
<td class="cell-title">{{ tm.title }}</td>
<td>
{% if tm.opponent %}
{{ tm.opponent }}
{% else %}
<span class="badge badge-info">Practice</span>
{% endif %}
</td>
<td>{{ tm.date.strftime('%m/%d/%Y') }}</td>
<td>
{% if tm.start_time and tm.end_time %}
{{ tm.start_time.strftime('%H:%M') }} - {{ tm.end_time.strftime('%H:%M') }}
{% else %}
TBD
{% endif %}
</td>
<td>{{ tm.location or '—' }}</td>
<td>
{% if mdata.total_count > 0 %}
<span title="{{ mdata.confirmed_count }} of {{ mdata.total_count }} confirmed">
{% if mdata.confirmed_count == mdata.total_count and mdata.total_count > 0 %}
✅ {{ mdata.confirmed_count }}/{{ mdata.total_count }}
{% elif mdata.confirmed_count > 0 %}
⏳ {{ mdata.confirmed_count }}/{{ mdata.total_count }}
{% else %}
❌ 0/{{ mdata.total_count }}
{% endif %}
</span>
{% else %}
<span class="text-muted"></span>
{% endif %}
</td>
<td>
{% if mdata.participant_id %}
<button class="btn btn-sm {% if mdata.is_confirmed %}btn-success{% else %}btn-outline{% endif %} presence-toggle-btn"
data-match-id="{{ tm.id }}"
data-participant-id="{{ mdata.participant_id }}"
onclick="togglePresence(this)">
{% if mdata.is_confirmed %}✅ Confirmed{% else %}Confirm{% endif %}
</button>
{% else %}
<span class="text-muted"></span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center py-3 text-muted">
<i class="fas fa-calendar-alt"></i> No upcoming matches scheduled.
</div>
{% endif %}
</div>
</div>
{% endfor %}
{% else %}
<div class="card">
<div class="card-body text-center py-5">
<div class="empty-state">
<i class="fas fa-users fa-3x text-muted mb-3"></i>
<h3>No Teams</h3>
<p class="text-muted">You are not currently assigned to any team.</p>
</div>
</div>
</div>
{% endif %}
<script>
function togglePresence(btn) {
var matchId = btn.getAttribute('data-match-id');
var participantId = btn.getAttribute('data-participant-id');
fetch('/team-matches/' + matchId + '/toggle-presence/' + participantId, {
method: 'POST',
headers: {
'X-CSRFToken': '{{ csrf_token() }}',
'Content-Type': 'application/json'
}
})
.then(function(response) { return response.json(); })
.then(function(data) {
if (data.is_confirmed) {
btn.classList.add('btn-success');
btn.classList.remove('btn-outline');
btn.innerHTML = '✅ Confirmed';
} else {
btn.classList.remove('btn-success');
btn.classList.add('btn-outline');
btn.innerHTML = 'Confirm';
}
location.reload();
})
.catch(function(error) {
console.error('Error:', error);
});
}
</script>
<style>
.team-staff-bar {
padding: 10px 20px;
background: #f8fafc;
border-bottom: 1px solid #e2e8f0;
}
.staff-row {
display: flex;
align-items: center;
gap: 24px;
flex-wrap: wrap;
}
.staff-group {
display: flex;
align-items: center;
gap: 8px;
}
.staff-label {
font-size: 0.8rem;
color: #64748b;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.5px;
white-space: nowrap;
}
.staff-label i {
margin-right: 3px;
font-size: 0.75rem;
}
.staff-items {
display: flex;
align-items: center;
gap: 6px;
flex-wrap: wrap;
}
.staff-tag {
display: inline-flex;
align-items: center;
gap: 5px;
background: #e0e7ff;
color: #3730a3;
padding: 3px 10px;
border-radius: 14px;
font-size: 0.82rem;
font-weight: 500;
line-height: 1.3;
}
.staff-tag.manager-tag {
background: #fef3c7;
color: #92400e;
}
.text-sm {
font-size: 0.82rem;
}
.presence-toggle-btn {
min-width: 100px;
}
/* Dark mode */
[data-theme="dark"] .team-staff-bar {
background: var(--bg-tertiary);
border-bottom-color: var(--border-color);
}
[data-theme="dark"] .staff-label {
color: var(--text-muted);
}
[data-theme="dark"] .staff-tag {
background: rgba(99, 102, 241, 0.2);
color: #a5b4fc;
}
[data-theme="dark"] .staff-tag.manager-tag {
background: rgba(229, 169, 57, 0.2);
color: #fcd34d;
}
</style>
{% endblock %}
+1 -14
View File
@@ -65,20 +65,7 @@
<div class="card-body">
<div class="detail-grid">
<div class="detail-item">
<span class="detail-label"><i class="fas fa-headset"></i> Games</span>
<span class="detail-value">
{% set games_list = user.get_games_list() %}
{% if games_list %}
{% for game in games_list %}
<span class="badge badge-esport">{{ game }}</span>
{% endfor %}
{% else %}
<span class="text-muted">Not specified</span>
{% endif %}
</span>
</div>
<div class="detail-item">
<span class="detail-label"><i class="fas fa-chart-line"></i> Games & TRN</span>
<span class="detail-label"><i class="fas fa-gamepad"></i> Gamertags</span>
<span class="detail-value">
{% set games_list = user.get_games_list() %}
{% if games_list %}
+149
View File
@@ -0,0 +1,149 @@
{% extends "layouts/base.html" %}
{% block title %}{% if match %}Edit{% else %}Schedule{% endif %} Team Match - TryoutPro{% endblock %}
{% block page_title %}{% if match %}Edit{% else %}Schedule{% endif %} Team Match{% endblock %}
{% block breadcrumb %}<span class="breadcrumb">Home / <a href="{{ url_for('team_matches.list_matches') }}">Team Matches</a> / {% if match %}Edit{% else %}New{% endif %}</span>{% endblock %}
{% block content %}
<div class="card mb-4">
<div class="card-header">
<h3><i class="fas fa-futbol"></i> {% if match %}Edit Match{% else %}Schedule New Match{% endif %} — {{ team.name }}</h3>
</div>
<div class="card-body">
<form method="POST" action="{% if match %}{{ url_for('team_matches.edit_match', match_id=match.id) }}{% else %}{{ url_for('team_matches.create_match', team_id=team.id) }}{% endif %}" class="form">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<div class="form-row">
<div class="form-group col-6">
<label for="title">Match Title</label>
<input type="text" id="title" name="title" class="form-input"
value="{{ match.title if match else 'Team Match — ' + team.name }}"
placeholder="e.g., Regular Season vs Opponent" required>
</div>
{% if not is_practice %}
<div class="form-group col-6">
<label for="opponent">Opponent (optional)</label>
<input type="text" id="opponent" name="opponent" class="form-input"
value="{{ match.opponent if match else '' }}"
placeholder="e.g., University of Toronto">
</div>
{% endif %}
</div>
<div class="form-row">
<div class="form-group col-4">
<label for="date">Date</label>
<input type="date" id="date" name="date" class="form-input"
value="{{ match.date.strftime('%Y-%m-%d') if match else '' }}"
required>
</div>
<div class="form-group col-4">
<label for="start_time">Start Time</label>
<input type="time" id="start_time" name="start_time" class="form-input"
value="{{ match.start_time.strftime('%H:%M') if match and match.start_time else '' }}">
</div>
<div class="form-group col-4">
<label for="end_time">End Time</label>
<input type="time" id="end_time" name="end_time" class="form-input"
value="{{ match.end_time.strftime('%H:%M') if match and match.end_time else '' }}">
<small class="text-muted">Auto-calculated if left empty (start + 30 min)</small>
</div>
</div>
<div class="form-row">
<div class="form-group col-6">
<label for="location">Location</label>
<input type="text" id="location" name="location" class="form-input"
value="{{ match.location if match else '' }}"
placeholder="e.g., Online, Gym A">
</div>
{% if match %}
<div class="form-group col-6">
<label for="status">Status</label>
<select id="status" name="status" class="form-select">
<option value="scheduled" {% if match.status == 'scheduled' %}selected{% endif %}>Scheduled</option>
<option value="completed" {% if match.status == 'completed' %}selected{% endif %}>Completed</option>
<option value="cancelled" {% if match.status == 'cancelled' %}selected{% endif %}>Cancelled</option>
</select>
</div>
{% endif %}
</div>
<div class="form-group">
<label for="description">Description (optional)</label>
<textarea id="description" name="description" class="form-input" rows="3"
placeholder="Additional details about the match...">{{ match.description if match else '' }}</textarea>
</div>
{% if not match %}
<!-- Player roster (pre-filled, read-only display) -->
<div class="card mt-4">
<div class="card-header">
<h4><i class="fas fa-users"></i> Team Roster (auto-included)</h4>
<span class="text-muted" style="font-size: 0.85rem;">All {{ team_players | length }} player(s) will be added automatically</span>
</div>
<div class="card-body">
{% if team_players %}
<div class="roster-list" style="display: flex; flex-wrap: wrap; gap: 8px;">
{% for tp in team_players %}
<span class="staff-tag">
{{ tp.player.username }}
{% if tp.status == 'substitute' %}
<span class="text-muted" style="font-size: 0.7rem;">(sub)</span>
{% endif %}
</span>
{% endfor %}
</div>
{% else %}
<p class="text-muted text-center py-3">
<i class="fas fa-users-slash"></i> No players on this team. Add players in the Teams page first.
</p>
{% endif %}
</div>
</div>
{% else %}
<!-- Edit mode: show participants with presence status -->
<div class="card mt-4">
<div class="card-header">
<h4><i class="fas fa-users"></i> Participants</h4>
</div>
<div class="card-body">
{% if match.participants %}
<table class="table">
<thead>
<tr>
<th>Player</th>
<th>Presence</th>
</tr>
</thead>
<tbody>
{% for p in match.participants.all() %}
<tr>
<td>{{ p.player.username if p.player else 'Unknown' }}</td>
<td>
{% if p.is_confirmed %}
<span class="badge badge-success">✅ Confirmed</span>
{% else %}
<span class="badge badge-warning">⏳ Pending</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted text-center">No participants recorded.</p>
{% endif %}
</div>
</div>
{% endif %}
<div class="form-actions mt-4">
<a href="{{ url_for('team_matches.list_matches') }}" class="btn btn-secondary">Cancel</a>
<button type="submit" class="btn btn-primary">
<i class="fas fa-save"></i> {% if match %}Save Changes{% else %}Schedule Match{% endif %}
</button>
</div>
</form>
</div>
</div>
{% endblock %}
+231
View File
@@ -0,0 +1,231 @@
{% extends "layouts/base.html" %}
{% block title %}Team Matches - TryoutPro{% endblock %}
{% block page_title %}Team Matches{% endblock %}
{% block breadcrumb %}<span class="breadcrumb">Home / Team Matches</span>{% endblock %}
{% block header_actions %}
{% if teams %}
<div class="header-actions">
<select id="teamSelect" class="form-select" style="width:200px;" onchange="window.location.href='/team-matches/' + this.value + '/create'">
<option value="">+ Schedule Match</option>
{% for t in teams %}
<option value="{{ t.id }}">{{ t.name }}</option>
{% endfor %}
</select>
</div>
{% endif %}
{% endblock %}
{% block content %}
{% if match_data %}
<div class="table-container">
<table class="table">
<thead>
<tr>
<th>Match</th>
<th>Team</th>
<th>Opponent</th>
<th>Date</th>
<th>Time</th>
<th>Location</th>
<th>Presence</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for item in match_data %}
{% set m = item.match %}
<tr>
<td class="cell-title">{{ m.title }}</td>
<td>
<span class="badge badge-info">{{ m.org_team.name }}</span>
</td>
<td>
{% if m.opponent %}
{{ m.opponent }}
{% else %}
<span class="badge badge-info">Practice</span>
{% endif %}
</td>
<td>{{ m.date.strftime('%m/%d/%Y') }}</td>
<td>
{% if m.start_time and m.end_time %}
{{ m.start_time.strftime('%H:%M') }} - {{ m.end_time.strftime('%H:%M') }}
{% else %}
TBD
{% endif %}
</td>
<td>{{ m.location or '—' }}</td>
<td>
{% if item.total_count > 0 %}
<div class="presence-bar" title="{{ item.confirmed_count }} of {{ item.total_count }} confirmed">
<div class="presence-progress">
{% set pct = (item.confirmed_count / item.total_count * 100) | int %}
<div class="presence-fill" style="width: {{ pct }}%;"></div>
</div>
<span class="presence-text">
{% if item.confirmed_count == item.total_count and item.total_count > 0 %}
✅ {{ item.confirmed_count }}/{{ item.total_count }}
{% elif item.confirmed_count > 0 %}
⏳ {{ item.confirmed_count }}/{{ item.total_count }}
{% else %}
❌ 0/{{ item.total_count }}
{% endif %}
</span>
</div>
<!-- Player presence details -->
<div class="presence-players">
{% for p in item.participants %}
<a href="{{ url_for('users.view_user', user_id=p.player.id) }}" class="presence-player-tag {% if p.is_confirmed %}confirmed{% else %}pending{% endif %}"
title="{{ p.player.username }}{% if p.is_confirmed %} - Confirmed{% else %} - Pending{% endif %}"
style="text-decoration: none;">
{{ p.player.username[:2] | upper }} {{ p.player.username }}
{% if p.is_confirmed %}✅{% else %}⏳{% endif %}
</a>
{% endfor %}
</div>
{% else %}
<span class="text-muted"></span>
{% endif %}
</td>
<td>
<span class="badge badge-{{ m.status }}">{{ m.status }}</span>
</td>
<td class="eval-actions">
{% set can_manage_this = (current_user.role in ['president', 'manager']) or (current_user.role == 'coach' and m.org_team.coaches.filter_by(id=current_user.id).first()) or (current_user.role == 'coach' and m.org_team.coach_id == current_user.id) %}
{% if can_manage_this %}
<a href="{{ url_for('team_matches.edit_match', match_id=m.id) }}" class="btn btn-sm btn-outline" title="Edit Match">
<i class="fas fa-edit"></i>
</a>
<form method="POST" action="{{ url_for('team_matches.delete_match', match_id=m.id) }}" class="inline-form" onsubmit="return confirm('Delete this match?')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<button type="submit" class="btn btn-sm btn-danger" title="Delete Match">
<i class="fas fa-trash"></i>
</button>
</form>
{% endif %}
<!-- Toggle presence for each participant if user is player -->
{% if current_user.role == 'player' %}
{% for p in item.participants %}
{% if p.player.id == current_user.id %}
<button class="btn btn-sm {% if p.is_confirmed %}btn-success{% else %}btn-outline{% endif %} presence-toggle-btn"
data-match-id="{{ m.id }}"
data-participant-id="{{ p.id }}"
onclick="togglePresence(this)">
{% if p.is_confirmed %}✅ Confirmed{% else %}Confirm{% endif %}
</button>
{% endif %}
{% endfor %}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="card">
<div class="card-body text-center py-5">
<div class="empty-state">
<i class="fas fa-futbol fa-3x text-muted mb-3"></i>
<h3>No Team Matches</h3>
<p class="text-muted">Regular season matches have not been scheduled yet.</p>
{% if teams %}
<div class="mt-3">
<select id="teamSelectEmpty" class="form-select" style="width:220px; display:inline;" onchange="window.location.href='/team-matches/' + this.value + '/create'">
<option value="">-- Schedule a Match --</option>
{% for t in teams %}
<option value="{{ t.id }}">{{ t.name }}</option>
{% endfor %}
</select>
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}
<script>
function togglePresence(btn) {
var matchId = btn.getAttribute('data-match-id');
var participantId = btn.getAttribute('data-participant-id');
fetch('/team-matches/' + matchId + '/toggle-presence/' + participantId, {
method: 'POST',
headers: {
'X-CSRFToken': '{{ csrf_token() }}',
'Content-Type': 'application/json'
}
})
.then(function(response) { return response.json(); })
.then(function(data) {
if (data.is_confirmed) {
btn.classList.add('btn-success');
btn.classList.remove('btn-outline');
btn.innerHTML = '✅ Confirmed';
} else {
btn.classList.remove('btn-success');
btn.classList.add('btn-outline');
btn.innerHTML = 'Confirm';
}
// Reload to update presence bar
location.reload();
})
.catch(function(error) {
console.error('Error:', error);
});
}
</script>
<style>
.presence-bar {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 4px;
}
.presence-progress {
width: 60px;
height: 6px;
background: #e5e7eb;
border-radius: 3px;
overflow: hidden;
}
.presence-fill {
height: 100%;
background: #10b981;
border-radius: 3px;
}
.presence-text {
font-size: 0.8rem;
font-weight: 600;
}
.presence-players {
display: flex;
flex-wrap: wrap;
gap: 3px;
margin-top: 3px;
}
.presence-player-tag {
display: inline-flex;
align-items: center;
gap: 2px;
padding: 1px 5px;
border-radius: 10px;
font-size: 0.7rem;
font-weight: 600;
}
.presence-player-tag.confirmed {
background: #d1fae5;
color: #065f46;
}
.presence-player-tag.pending {
background: #fef3c7;
color: #92400e;
}
.presence-toggle-btn {
margin-left: 4px;
}
</style>
{% endblock %}
+204 -31
View File
@@ -59,34 +59,6 @@
<div class="card-header">
<h3><i class="fas fa-users-cog"></i> {{ team.name }}</h3>
<div class="card-actions">
<div class="team-staff">
{% if team.coach %}
<span class="text-muted">Coach: {{ team.coach.username }}</span>
{% if can_manage %}
<form method="POST" action="{{ url_for('teams.remove_coach', team_id=team.id) }}" class="inline-form" onsubmit="return confirm('Remove coach {{ team.coach.username }} from {{ team.name }}?')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<button type="submit" class="btn btn-sm btn-outline-danger" title="Remove Coach">
<i class="fas fa-user-minus"></i>
</button>
</form>
{% endif %}
{% else %}
<span class="text-muted">No coach assigned</span>
{% endif %}
{% if team.manager %}
<span class="text-muted ml-2">Manager: {{ team.manager.username }}</span>
{% if can_manage %}
<form method="POST" action="{{ url_for('teams.remove_manager', team_id=team.id) }}" class="inline-form" onsubmit="return confirm('Remove manager {{ team.manager.username }} from {{ team.name }}?')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<button type="submit" class="btn btn-sm btn-outline-danger" title="Remove Manager">
<i class="fas fa-user-minus"></i>
</button>
</form>
{% endif %}
{% else %}
<span class="text-muted ml-2">No manager assigned</span>
{% endif %}
</div>
{% if can_manage %}
<button class="btn btn-sm btn-outline edit-team-btn" data-team-id="{{ team.id }}" data-team-name="{{ team.name }}" data-coach-id="{{ team.coach_id or '' }}" data-manager-id="{{ team.manager_id or '' }}">
<i class="fas fa-edit"></i> Edit
@@ -105,6 +77,92 @@
{% endif %}
</div>
</div>
<!-- Full-width staff bar for coaches and managers -->
<div class="team-staff-bar">
<div class="staff-row">
<div class="staff-group">
<span class="staff-label"><i class="fas fa-chalkboard-teacher"></i> Coaches</span>
<div class="staff-items">
{% set team_coaches = team.get_coaches() %}
{% if team_coaches %}
{% for c in team_coaches %}
<span class="staff-tag">
{{ c.username }}
{% if can_manage %}
<form method="POST" action="{{ url_for('teams.remove_coach', team_id=team.id) }}" class="inline-form" onsubmit="return confirm('Remove coach {{ c.username }} from {{ team.name }}?')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<input type="hidden" name="coach_id" value="{{ c.id }}"/>
<button type="submit" class="btn-icon-sm" title="Remove Coach">&times;</button>
</form>
{% endif %}
</span>
{% endfor %}
{% else %}
<span class="text-muted text-sm">None assigned</span>
{% endif %}
</div>
</div>
<div class="staff-group">
<span class="staff-label"><i class="fas fa-user-tie"></i> Managers</span>
<div class="staff-items">
{% set team_managers = team.get_managers() %}
{% if team_managers %}
{% for m in team_managers %}
<span class="staff-tag manager-tag">
{{ m.username }}
{% if can_manage %}
<form method="POST" action="{{ url_for('teams.remove_manager', team_id=team.id) }}" class="inline-form" onsubmit="return confirm('Remove manager {{ m.username }} from {{ team.name }}?')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<input type="hidden" name="manager_id" value="{{ m.id }}"/>
<button type="submit" class="btn-icon-sm" title="Remove Manager">&times;</button>
</form>
{% endif %}
</span>
{% endfor %}
{% else %}
<span class="text-muted text-sm">None assigned</span>
{% endif %}
</div>
</div>
{% if can_manage %}
<div class="staff-add-forms">
<form method="POST" action="{{ url_for('teams.add_coach', team_id=team.id) }}" class="inline-form">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<select name="coach_id" class="form-select form-select-sm" onchange="if(this.value) this.form.submit()">
<option value="">+ Add Coach</option>
{% for c in coaches %}
{% if c.id not in (team_coaches | map(attribute='id') | list) %}
<option value="{{ c.id }}">{{ c.username }}</option>
{% endif %}
{% endfor %}
</select>
</form>
<form method="POST" action="{{ url_for('teams.add_manager', team_id=team.id) }}" class="inline-form">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<select name="manager_id" class="form-select form-select-sm" onchange="if(this.value) this.form.submit()">
<option value="">+ Add Manager</option>
{% for m in managers %}
{% if m.id not in (team_managers | map(attribute='id') | list) %}
<option value="{{ m.id }}">{{ m.username }}</option>
{% endif %}
{% endfor %}
</select>
</form>
</div>
{% endif %}
<a href="{{ url_for('team_matches.list_matches') }}?team_id={{ team.id }}" class="btn btn-sm btn-outline" title="View Team Matches">
<i class="fas fa-futbol"></i> Matches
</a>
{% if current_user.can_schedule_matches() and (current_user.role in ['president', 'manager'] or (current_user.role == 'coach' and team.coaches.filter_by(id=current_user.id).first()) or (current_user.role == 'coach' and team.coach_id == current_user.id)) %}
<a href="{{ url_for('team_matches.create_match', team_id=team.id) }}" class="btn btn-sm btn-success" title="Schedule Team Match">
<i class="fas fa-plus"></i> Match
</a>
<a href="{{ url_for('team_matches.create_match', team_id=team.id, type='practice') }}" class="btn btn-sm btn-info" title="Schedule Practice">
<i class="fas fa-dumbbell"></i> Practice
</a>
{% endif %}
</div>
</div>
<div class="card-body">
<div class="table-container">
<table class="table">
@@ -126,7 +184,7 @@
<td>
<div class="user-mini">
<div class="avatar-sm">{{ entry.player.username[:2] | upper }}</div>
<span>{{ entry.player.username }}</span>
<a href="{{ url_for('users.view_user', user_id=entry.player.id) }}">{{ entry.player.username }}</a>
</div>
</td>
<td>
@@ -326,14 +384,93 @@ function hideEditForm() {
}
</script>
<style>
.team-staff {
/* === Full-width staff bar layout === */
.team-staff-bar {
padding: 10px 20px;
background: #f8fafc;
border-bottom: 1px solid #e2e8f0;
}
.staff-row {
display: flex;
align-items: center;
gap: 24px;
flex-wrap: wrap;
}
.staff-group {
display: flex;
align-items: center;
gap: 8px;
}
.team-staff .text-muted {
.staff-label {
font-size: 0.8rem;
color: #64748b;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.5px;
white-space: nowrap;
}
.staff-label i {
margin-right: 3px;
font-size: 0.75rem;
}
.staff-items {
display: flex;
align-items: center;
gap: 6px;
flex-wrap: wrap;
}
.staff-tag {
display: inline-flex;
align-items: center;
gap: 5px;
background: #e0e7ff;
color: #3730a3;
padding: 3px 10px;
border-radius: 14px;
font-size: 0.82rem;
font-weight: 500;
line-height: 1.3;
}
.staff-tag.manager-tag {
background: #fef3c7;
color: #92400e;
}
.staff-tag .btn-icon-sm {
background: none;
border: none;
color: #ef4444;
cursor: pointer;
padding: 0;
font-size: 0.85rem;
font-weight: 700;
line-height: 1;
margin-left: 1px;
}
.staff-tag .btn-icon-sm:hover {
color: #dc2626;
}
.staff-add-forms {
display: flex;
align-items: center;
gap: 8px;
margin-left: auto;
}
.staff-add-forms .form-select-sm {
font-size: 0.8rem;
padding: 4px 28px 4px 10px;
height: auto;
border-radius: 6px;
border: 1px dashed #cbd5e1;
background: #fff;
min-width: 150px;
}
.staff-add-forms .form-select-sm:focus {
border-color: #6366f1;
outline: none;
box-shadow: 0 0 0 2px rgba(99,102,241,0.15);
}
.text-sm {
font-size: 0.82rem;
}
.ml-2 {
margin-left: 8px;
@@ -342,5 +479,41 @@ function hideEditForm() {
cursor: pointer;
min-width: 90px;
}
/* === Dark mode overrides for staff bar === */
[data-theme="dark"] .team-staff-bar {
background: var(--bg-tertiary);
border-bottom-color: var(--border-color);
}
[data-theme="dark"] .staff-label {
color: var(--text-muted);
}
[data-theme="dark"] .staff-tag {
background: rgba(99, 102, 241, 0.2);
color: #a5b4fc;
}
[data-theme="dark"] .staff-tag.manager-tag {
background: rgba(229, 169, 57, 0.2);
color: #fcd34d;
}
[data-theme="dark"] .staff-tag .btn-icon-sm {
color: var(--text-muted);
}
[data-theme="dark"] .staff-tag .btn-icon-sm:hover {
color: var(--danger);
}
[data-theme="dark"] .staff-add-forms .form-select-sm {
background: var(--input-bg);
border-color: var(--border-color);
color: var(--text-secondary);
}
[data-theme="dark"] .staff-add-forms .form-select-sm:focus {
border-color: var(--primary);
box-shadow: 0 0 0 2px rgba(0, 152, 76, 0.25);
}
[data-theme="dark"] .staff-add-forms .form-select-sm option {
background: var(--bg-secondary);
color: var(--text-primary);
}
</style>
{% endblock %}
+22 -10
View File
@@ -127,6 +127,8 @@
<th>Status</th>
{% if current_user.can_evaluate() %}
<th>Evaluation</th>
{% endif %}
{% if can_edit %}
<th>Actions</th>
{% endif %}
</tr>
@@ -138,7 +140,7 @@
<td>
<div class="user-mini">
<div class="avatar-sm">{{ p.username[:2] | upper }}</div>
<span>{{ p.username }}</span>
<a href="{{ url_for('users.view_user', user_id=p.id) }}">{{ p.username }}</a>
</div>
</td>
<td>
@@ -163,19 +165,29 @@
<span class="badge badge-warning">Pending</span>
{% endif %}
</td>
<td class="eval-actions">
<a href="{{ url_for('evaluations.evaluate_player', tryout_id=tryout.id, player_id=p.id) }}" class="btn btn-sm btn-primary" title="Evaluate player">
<i class="fas fa-edit"></i> {% if player_eval_status.get(p.id) %}Edit{% else %}Evaluate{% endif %}
</a>
<a href="{{ url_for('users.add_note_from_tryout', tryout_id=tryout.id) }}?player_id={{ p.id }}" class="btn btn-sm btn-outline" title="Add note for {{ p.username }}">
<i class="fas fa-sticky-note"></i>
</a>
</td>
{% endif %}
{% if can_edit %}
<td class="eval-actions">
{% if current_user.can_evaluate() %}
<a href="{{ url_for('evaluations.evaluate_player', tryout_id=tryout.id, player_id=p.id) }}" class="btn btn-sm btn-primary" title="Evaluate player">
<i class="fas fa-edit"></i> {% if player_eval_status.get(p.id) %}Edit{% else %}Evaluate{% endif %}
</a>
<a href="{{ url_for('users.add_note_from_tryout', tryout_id=tryout.id) }}?player_id={{ p.id }}" class="btn btn-sm btn-outline" title="Add note for {{ p.username }}">
<i class="fas fa-sticky-note"></i>
</a>
{% endif %}
<form method="POST" action="{{ url_for('tryouts.remove_player', tryout_id=tryout.id, player_id=p.id) }}" class="inline-form" onsubmit="return confirm('Remove {{ p.username }} from this tryout? This will also remove them from all teams and matches within this tryout.');">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<button type="submit" class="btn btn-sm btn-danger" title="Remove player from tryout">
<i class="fas fa-user-minus"></i> Remove
</button>
</form>
</td>
{% endif %}
</tr>
{% else %}
<tr>
<td colspan="{% if current_user.can_evaluate() %}4{% else %}2{% endif %}" class="text-center">
<td colspan="{% if can_edit %}{% if current_user.can_evaluate() %}5{% else %}4{% endif %}{% else %}{% if current_user.can_evaluate() %}4{% else %}2{% endif %}{% endif %}" class="text-center">
No players registered yet.
</td>
</tr>
+76
View File
@@ -0,0 +1,76 @@
{% extends "layouts/base.html" %}
{% block title %}{{ profile_user.username }} - TryoutPro{% endblock %}
{% block page_title %}{{ profile_user.username }}{% endblock %}
{% block breadcrumb %}<span class="breadcrumb">Home / <a href="#" onclick="history.back()">Back</a> / {{ profile_user.username }}</span>{% endblock %}
{% block content %}
<div class="card mb-4">
<div class="card-header">
<div class="user-mini" style="gap: 12px;">
<div class="avatar-sm" style="width: 48px; height: 48px; font-size: 1.2rem;">
{{ profile_user.username[:2] | upper }}
</div>
<div>
<h3 style="margin: 0;">{{ profile_user.username }}</h3>
<span class="badge badge-{{ 'info' if profile_user.role == 'player' else 'primary' }}">{{ profile_user.role | capitalize }}</span>
</div>
</div>
</div>
<div class="card-body">
<div class="detail-grid">
<div class="detail-item">
<span class="detail-label">Username</span>
<span class="detail-value">{{ profile_user.username }}</span>
</div>
<div class="detail-item">
<span class="detail-label">Role</span>
<span class="detail-value">
<span class="badge badge-{{ 'info' if profile_user.role == 'player' else 'primary' }}">{{ profile_user.role | capitalize }}</span>
</span>
</div>
{% if profile_user.discord_username %}
<div class="detail-item">
<span class="detail-label">Discord</span>
<span class="detail-value">{{ profile_user.discord_username }}</span>
</div>
{% endif %}
</div>
{% set gamertags = profile_user.gamertags %}
{% if gamertags %}
<hr class="my-4">
<h4 class="mb-3"><i class="fas fa-gamepad"></i> Gamertags</h4>
<div class="table-container">
<table class="table">
<thead>
<tr>
<th>Game</th>
<th>Gamertag</th>
<th>Platform</th>
<th>Profile</th>
</tr>
</thead>
<tbody>
{% for gt in gamertags %}
<tr>
<td>{{ gt.game }}</td>
<td>{{ gt.gamertag }}</td>
<td>{{ gt.platform or '-' }}</td>
<td>
{% if gt.get_trn_url() %}
<a href="{{ gt.get_trn_url() }}" target="_blank" class="btn btn-sm btn-outline trn-link">
<i class="fas fa-external-link-alt"></i> View Profile
</a>
{% else %}
<span class="text-muted"></span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
</div>
{% endblock %}