summaryrefslogtreecommitdiff
path: root/app/views/matches
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/matches')
-rw-r--r--app/views/matches/_form.html.erb19
-rw-r--r--app/views/matches/index.html.erb11
-rw-r--r--app/views/matches/new.html.erb2
-rw-r--r--app/views/matches/show.html.erb29
4 files changed, 28 insertions, 33 deletions
diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb
index 727c002..3efb566 100644
--- a/app/views/matches/_form.html.erb
+++ b/app/views/matches/_form.html.erb
@@ -1,16 +1,5 @@
-<%= form_for(@match) do |f| %>
- <% if @match.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:</h2>
-
- <ul>
- <% @match.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
+<%= form_for([@tournament, @tournament.matches.build]) do |f| %>
+
<div class="field">
<%= f.label :status %><br>
<%= f.number_field :status %>
@@ -23,10 +12,6 @@
<%= f.label :name %><br>
<%= f.text_field :name %>
</div>
- <div class="field">
- <%= f.label :winner_id %><br>
- <%= f.text_field :winner_id %>
- </div>
<div class="actions">
<%= f.submit %>
</div>
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb
index 400efb4..d862d57 100644
--- a/app/views/matches/index.html.erb
+++ b/app/views/matches/index.html.erb
@@ -14,15 +14,16 @@
</thead>
<tbody>
- <% @matches.each do |match| %>
+ <% @tournament.matches.each do |match| %>
<tr>
+ <td><%= match.tournament.id %></td>
<td><%= match.status %></td>
<td><%= match.tournament %></td>
<td><%= match.name %></td>
<td><%= match.winner %></td>
- <td><%= link_to 'Show', match %></td>
- <td><%= link_to 'Edit', edit_match_path(match) %></td>
- <td><%= link_to 'Destroy', match, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ <td><%= link_to 'Show', tournament_match_path(@tournament, match) %></td>
+ <td><%= link_to 'Edit', edit_tournament_match_path(@tournament, match) %></td>
+ <td><%= link_to 'Destroy', tournament_match_path(@tournament, match), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
@@ -30,4 +31,4 @@
<br>
-<%= link_to 'New Match', new_match_path %>
+<%= link_to 'New Match', new_tournament_match_path %>
diff --git a/app/views/matches/new.html.erb b/app/views/matches/new.html.erb
index bd4c78c..74e7e3a 100644
--- a/app/views/matches/new.html.erb
+++ b/app/views/matches/new.html.erb
@@ -1,5 +1,3 @@
<h1>New match</h1>
<%= render 'form' %>
-
-<%= link_to 'Back', matches_path %>
diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb
index f3fc822..6b962ad 100644
--- a/app/views/matches/show.html.erb
+++ b/app/views/matches/show.html.erb
@@ -1,5 +1,3 @@
-<p id="notice"><%= notice %></p>
-
<p>
<strong>Status:</strong>
<%= @match.status %>
@@ -7,7 +5,7 @@
<p>
<strong>Tournament:</strong>
- <%= @match.tournament %>
+ <%= @match.tournament.id %>
</p>
<p>
@@ -15,10 +13,23 @@
<%= @match.name %>
</p>
-<p>
- <strong>Winner:</strong>
- <%= @match.winner %>
-</p>
+<% if (@tournament.hosts.include?(current_user) and @match.winner.nil?) %>
+ <%= form_for([@tournament, @match], method: "put") do |f| %>
+ <ul>
+ <% @match.teams.each do |team| %>
+ <li><label><%= f.radio_button(:winner, team.id) %>
+ <%= team.users.collect{|u| u.user_name}.join(", ") %></label></li>
+ <% end %>
+ </ul>
+ <%= f.submit("Select winner") %>
+ <% end %>
+<% end %>
+
+<% unless @match.winner.nil? %>
+ <p>
+ <strong>Winner:</strong>
+ <%= @match.winner.users.collect{|u| u.user_name}.join(", ") %>
+ </p>
+<% end %>
-<%= link_to 'Edit', edit_match_path(@match) %> |
-<%= link_to 'Back', matches_path %>
+<%= link_to 'Back', tournament_matches_path %>