Ajout du joueur responsable
CI - Security, Lint & Tests / validate (push) Canceled after 0s

This commit is contained in:
cedrick2711
2026-09-27 14:25:29 -04:00
parent bd9ed4bdc7
commit 2e5903b131
18 changed files with 795 additions and 14 deletions
+13
View File
@@ -10,6 +10,16 @@
<div class="card mb-4">
<div class="card-header">
<h3><i class="fas fa-users"></i> {{ team.name }}</h3>
<div class="card-actions">
{% if current_user.can_manage_team_matches(team) %}
<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>
<!-- Staff bar -->
<div class="team-staff-bar">
@@ -61,6 +71,9 @@
<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>
{% if entry.is_team_representative %}
<span class="badge badge-info" title="{{ _('Team representative') }}">{{ _('Representative') }}</span>
{% endif %}
</div>
</td>
<td>
+1 -1
View File
@@ -93,7 +93,7 @@
<span class="badge badge-{{ m.status }}">{{ m.status }}</span>
</td>
<td class="eval-actions">
{% set can_manage_this = (current_user.role in ['admin', '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) %}
{% set can_manage_this = current_user.can_manage_team_matches(m.org_team) %}
{% 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>
+44 -1
View File
@@ -127,7 +127,7 @@
<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 ['admin', '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)) %}
{% if current_user.can_manage_team_matches(team) %}
<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>
@@ -159,6 +159,9 @@
<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>
{% if entry.is_team_representative %}
<span class="badge badge-info" title="{{ _('Team representative') }}">{{ _('Representative') }}</span>
{% endif %}
</div>
</td>
<td>
@@ -180,6 +183,16 @@
<td>{{ entry.player.phone or '-' }}</td>
{% if can_manage_team %}
<td>
{% if current_user.can_designate_team_representative() %}
<button type="button"
class="btn btn-sm representative-toggle-btn {% if entry.is_team_representative %}btn-warning{% else %}btn-outline{% endif %}"
data-team-id="{{ team.id }}"
data-player-id="{{ entry.player.id }}"
data-action="toggle-representative"
title="{{ _('Name as team representative') }}">
<i class="fas fa-star"></i>
</button>
{% endif %}
<form method="POST" data-ajax action="{{ url_for('teams.remove_player', team_id=team.id, player_id=entry.player.id) }}" class="inline-form" data-confirm="{{ _('Remove %(player)s from %(team)s?', player=entry.player.username, team=team.name) }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<button type="submit" class="btn btn-sm btn-danger">
@@ -341,6 +354,35 @@ function toggleStatus(btn) {
});
}
function toggleRepresentative(btn) {
var teamId = btn.getAttribute('data-team-id');
var playerId = btn.getAttribute('data-player-id');
fetch('/teams/' + teamId + '/toggle_representative/' + playerId, {
method: 'POST',
headers: {
'X-CSRFToken': '{{ csrf_token() }}',
'Content-Type': 'application/json'
}
})
.then(function(response) { return response.json(); })
.then(function(data) {
if (data.success) {
if (data.is_team_representative) {
btn.classList.remove('btn-outline');
btn.classList.add('btn-warning');
} else {
btn.classList.remove('btn-warning');
btn.classList.add('btn-outline');
}
window.TT.refreshPage(window.location.pathname);
}
})
.catch(function(error) {
console.error('Error:', error);
});
}
var currentEditTeamId = null;
document.addEventListener('DOMContentLoaded', function() {
@@ -416,6 +458,7 @@ registerActions({
'hide-create-form': hideCreateForm,
'hide-edit-form': hideEditForm,
'toggle-status': toggleStatus,
'toggle-representative': toggleRepresentative,
});
</script>
<style>