summaryrefslogtreecommitdiff
path: root/app/views/matches
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-03-07 00:41:47 -0500
committerAndrewMurrell <amurrel@purdue.edu>2014-03-07 00:41:47 -0500
commitfd213819fa004209fc466b19ee65d83b1f918068 (patch)
treeecfe47daa486da7d878207ac6a799b6fab79deab /app/views/matches
parent5ca9bd493d0348d56a3a8ce56923a72230515fe0 (diff)
parent8fc6b48caccdb8fbfe04e41282444e0b916883b3 (diff)
Merge branch 'master' of http://github.com/LukeShu/leaguer
Diffstat (limited to 'app/views/matches')
-rw-r--r--app/views/matches/_form.html.erb4
-rw-r--r--app/views/matches/index.html.erb2
-rw-r--r--app/views/matches/index.json.jbuilder2
-rw-r--r--app/views/matches/show.html.erb24
-rw-r--r--app/views/matches/show.json.jbuilder2
5 files changed, 31 insertions, 3 deletions
diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb
index 015aed0..67d30da 100644
--- a/app/views/matches/_form.html.erb
+++ b/app/views/matches/_form.html.erb
@@ -8,6 +8,10 @@
<%= 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 d635834..ff42ef1 100644
--- a/app/views/matches/index.html.erb
+++ b/app/views/matches/index.html.erb
@@ -5,6 +5,7 @@
<tr>
<th>Tournament</th>
<th>Name</th>
+ <th>Winner</th>
<th></th>
<th></th>
<th></th>
@@ -16,6 +17,7 @@
<tr>
<td><%= match.tournament %></td>
<td><%= match.name %></td>
+ <td><%= match.winner %></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>
diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder
index 08ae0ef..0b2bfcd 100644
--- a/app/views/matches/index.json.jbuilder
+++ b/app/views/matches/index.json.jbuilder
@@ -1,4 +1,4 @@
json.array!(@matches) do |match|
- json.extract! match, :id, :tournament_id, :name
+ json.extract! match, :id, :tournament_id, :name, :winner_id
json.url match_url(match, format: :json)
end
diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb
index e95cd07..f5a3686 100644
--- a/app/views/matches/show.html.erb
+++ b/app/views/matches/show.html.erb
@@ -1,6 +1,6 @@
<p>
<strong>Tournament:</strong>
- <%= @match.tournament %>
+ <%= @match.tournament.id %>
</p>
<p>
@@ -8,5 +8,27 @@
<%= @match.name %>
</p>
+<% if @tournament.hosts.include?(current_user) %>
+ <%= form_for(@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 %>
+
<%= link_to 'Edit', edit_tournament_match_path(@tournament, @match) %> |
<%= link_to 'Back', tournament_matches_path %>
+
+<% 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 %>
+
diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder
index 128550f..fe14010 100644
--- a/app/views/matches/show.json.jbuilder
+++ b/app/views/matches/show.json.jbuilder
@@ -1 +1 @@
-json.extract! @match, :id, :tournament_id, :name, :created_at, :updated_at
+json.extract! @match, :id, :tournament_id, :name, :winner_id, :created_at, :updated_at