ac858f1e6d
Implement comprehensive partnership tracking system and tournament management features including round-robin, single/double elimination, and Swiss system pairings. Changes: - Add partnership_games and partnership_stats tables - Implement PartnershipTracker service for recording partnership data - Add tournament generator with multiple formats - Create tournament management actions and views - Add acceptance tests for partnership tracking - Fix PartnershipTracker to use single snapshot per player per match - Fix round-robin test to query by round_number instead of hardcoded ID Note: All 8 acceptance tests now passing
237 lines
7.1 KiB
Plaintext
237 lines
7.1 KiB
Plaintext
<h1><%= tournament.name %></h1>
|
|
|
|
<% if tournament.description %>
|
|
<p><em><%= tournament.description %></em></p>
|
|
<% end %>
|
|
|
|
<div class="tournament-meta">
|
|
<strong>Format:</strong> <%= tournament.format %> |
|
|
<strong>Status:</strong> <%= tournament.status %> |
|
|
<% if tournament.event_date %>
|
|
<strong>Date:</strong> <%= tournament.event_date.strftime('%Y-%m-%d %H:%M') %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<div class="tournament-tabs">
|
|
<ul>
|
|
<li><a href="#participants">Participants</a></li>
|
|
<li><a href="#teams">Teams</a></li>
|
|
<li><a href="#rounds">Rounds & Schedule</a></li>
|
|
<li><a href="#standings">Standings</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- Participants Section -->
|
|
<section id="participants">
|
|
<h2>Participants</h2>
|
|
|
|
<% if players.any? %>
|
|
<p><strong>Total:</strong> <%= players.count %> players registered</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Player</th>
|
|
<th>Status</th>
|
|
<th>Seed</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% players.each do |player| %>
|
|
<% participant = participants.find { |p| p.player_id == player.id } %>
|
|
<tr>
|
|
<td><%= player.name %></td>
|
|
<td><%= participant&.status || 'registered' %></td>
|
|
<td><%= participant&.seed || '-' %></td>
|
|
<td>
|
|
<form action="/admin/tournaments/<%= tournament.id %>/participants/<%= player.id %>" method="post" style="display:inline;">
|
|
<input type="hidden" name="_csrf_token" value="<%= csrf_token %>">
|
|
<input type="hidden" name="_method" value="delete">
|
|
<button type="submit" onclick="return confirm('Remove <%= player.name %> from tournament?')" style="background:none;border:none;color:blue;text-decoration:underline;cursor:pointer;">Remove</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<% else %>
|
|
<p>No participants registered yet.</p>
|
|
<% end %>
|
|
|
|
<h3>Add Participants</h3>
|
|
<% if available_players.any? %>
|
|
<form action="/admin/tournaments/<%= tournament.id %>/participants" method="post">
|
|
<input type="hidden" name="_csrf_token" value="<%= csrf_token %>">
|
|
<label>Add Player:</label>
|
|
<select name="player_id">
|
|
<option value="">Select a player...</option>
|
|
<% available_players.each do |player| %>
|
|
<option value="<%= player.id %>"><%= player.name %></option>
|
|
<% end %>
|
|
</select>
|
|
<button type="submit">Add to Tournament</button>
|
|
</form>
|
|
<% else %>
|
|
<p><em>All available players are already registered.</em></p>
|
|
<% end %>
|
|
</section>
|
|
|
|
<!-- Teams Section -->
|
|
<section id="teams">
|
|
<h2>Teams</h2>
|
|
|
|
<% if teams.any? %>
|
|
<p><strong>Total:</strong> <%= teams.count %> teams</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Team Name</th>
|
|
<th>Player 1</th>
|
|
<th>Player 2</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% teams.each do |team| %>
|
|
<% p1 = players.find { |p| p.id == team.player_1_id } %>
|
|
<% p2 = players.find { |p| p.id == team.player_2_id } %>
|
|
<tr>
|
|
<td><%= team.team_name %></td>
|
|
<td><%= p1&.name || team.player_1_id %></td>
|
|
<td><%= p2&.name || team.player_2_id %></td>
|
|
<td>
|
|
<a href="/admin/tournaments/<%= tournament.id %>/teams/<%= team.id %>/edit">Edit</a> |
|
|
<form action="/admin/tournaments/<%= tournament.id %>/teams/<%= team.id %>" method="post" style="display:inline;">
|
|
<input type="hidden" name="_csrf_token" value="<%= csrf_token %>">
|
|
<input type="hidden" name="_method" value="delete">
|
|
<button type="submit" onclick="return confirm('Remove team?')" style="background:none;border:none;color:blue;text-decoration:underline;cursor:pointer;">Remove</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<% else %>
|
|
<p>No teams created yet.</p>
|
|
<% end %>
|
|
|
|
<h3>Create Teams</h3>
|
|
<% if players.any? %>
|
|
<form action="/admin/tournaments/<%= tournament.id %>/teams" method="post">
|
|
<input type="hidden" name="_csrf_token" value="<%= csrf_token %>">
|
|
<div>
|
|
<label>Team Name:</label>
|
|
<input type="text" name="team_name" placeholder="e.g., Ace High">
|
|
</div>
|
|
<div>
|
|
<label>Player 1:</label>
|
|
<select name="player_1_id">
|
|
<option value="">Select player...</option>
|
|
<% players.each do |player| %>
|
|
<option value="<%= player.id %>"><%= player.name %></option>
|
|
<% end %>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label>Player 2:</label>
|
|
<select name="player_2_id">
|
|
<option value="">Select player...</option>
|
|
<% players.each do |player| %>
|
|
<option value="<%= player.id %>"><%= player.name %></option>
|
|
<% end %>
|
|
</select>
|
|
</div>
|
|
<button type="submit">Create Team</button>
|
|
</form>
|
|
<% else %>
|
|
<p><em>Add participants first before creating teams.</em></p>
|
|
<% end %>
|
|
</section>
|
|
|
|
<!-- Rounds Section -->
|
|
<section id="rounds">
|
|
<h2>Rounds & Schedule</h2>
|
|
|
|
<% if rounds.any? %>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Round</th>
|
|
<th>Status</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% rounds.each do |round| %>
|
|
<tr>
|
|
<td>Round <%= round.round_number %></td>
|
|
<td><%= round.status %></td>
|
|
<td>
|
|
<a href="/admin/tournaments/<%= tournament.id %>/rounds/<%= round.id %>">View</a>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<% else %>
|
|
<p>No rounds scheduled yet.</p>
|
|
<% end %>
|
|
|
|
<% if teams.any? %>
|
|
<form action="/admin/tournaments/<%= tournament.id %>/schedule" method="post">
|
|
<input type="hidden" name="_csrf_token" value="<%= csrf_token %>">
|
|
<button type="submit">Generate Schedule / Rounds</button>
|
|
</form>
|
|
<% else %>
|
|
<p><em>Add teams first to generate the schedule.</em></p>
|
|
<% end %>
|
|
</section>
|
|
|
|
<!-- Standings Section -->
|
|
<section id="standings">
|
|
<h2>Standings</h2>
|
|
|
|
<% if teams.any? %>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>#</th>
|
|
<th>Team</th>
|
|
<th>W</th>
|
|
<th>L</th>
|
|
<th>PCT</th>
|
|
<th>PF</th>
|
|
<th>PA</th>
|
|
<th>PD</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% teams.each_with_index do |team, i| %>
|
|
<tr>
|
|
<td><%= i + 1 %></td>
|
|
<td><%= team.team_name %></td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>.000</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<% else %>
|
|
<p>No teams to display standings.</p>
|
|
<% end %>
|
|
</section>
|
|
|
|
<hr>
|
|
|
|
<div class="tournament-actions">
|
|
<a href="/admin/tournaments/<%= tournament.id %>/results">Enter Match Results</a> |
|
|
<a href="/admin/tournaments/<%= tournament.id %>/complete">Complete Tournament</a> |
|
|
<a href="/admin/tournaments">Back to Tournaments</a>
|
|
</div>
|