From 53b4f8028fc987b0cf26a7a073fec7064b4b6d8a Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Tue, 25 Mar 2014 17:38:38 -0400 Subject: revert Guntas --- app/views/matches/_form.html.erb | 23 ++--------------------- app/views/matches/index.html.erb | 14 ++++++-------- app/views/matches/index.json.jbuilder | 2 +- app/views/matches/new.html.erb | 2 -- app/views/matches/show.html.erb | 34 ++++++++++++++++++++-------------- app/views/matches/show.json.jbuilder | 2 +- 6 files changed, 30 insertions(+), 47 deletions(-) (limited to 'app/views/matches') diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb index 727c002..015aed0 100644 --- a/app/views/matches/_form.html.erb +++ b/app/views/matches/_form.html.erb @@ -1,20 +1,5 @@ -<%= form_for(@match) do |f| %> - <% if @match.errors.any? %> -
-

<%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:

- - -
- <% end %> - -
- <%= f.label :status %>
- <%= f.number_field :status %> -
+<%= form_for([@tournament, @tournament.matches.build]) do |f| %> +
<%= f.label :tournament_id %>
<%= f.text_field :tournament_id %> @@ -23,10 +8,6 @@ <%= f.label :name %>
<%= f.text_field :name %>
-
- <%= f.label :winner_id %>
- <%= f.text_field :winner_id %> -
<%= f.submit %>
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 400efb4..60df1b5 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -3,7 +3,6 @@ - @@ -14,15 +13,14 @@ - <% @matches.each do |match| %> + <% @tournament.matches.each do |match| %> - - + - - - + + + <% end %> @@ -30,4 +28,4 @@
-<%= link_to 'New Match', new_match_path %> +<%= link_to 'New Match', new_tournament_match_path %> diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder index 1a63f5f..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, :status, :tournament_id, :name, :winner_id + json.extract! match, :id, :tournament_id, :name, :winner_id json.url match_url(match, format: :json) end 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 @@

New match

<%= 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..b6930ea 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -1,13 +1,6 @@ -

<%= notice %>

- -

- Status: - <%= @match.status %> -

-

Tournament: - <%= @match.tournament %> + <%= @match.tournament.id %>

@@ -15,10 +8,23 @@ <%= @match.name %>

-

- Winner: - <%= @match.winner %> -

+<% if (@tournament.hosts.include?(current_user) and @match.winner.nil?) %> + <%= form_for([@tournament, @match], method: "put") do |f| %> + + <%= f.submit("Select winner") %> + <% end %> +<% end %> + +<% unless @match.winner.nil? %> +

+ Winner: + <%= @match.winner.users.collect{|u| u.user_name}.join(", ") %> +

+<% end %> -<%= link_to 'Edit', edit_match_path(@match) %> | -<%= link_to 'Back', matches_path %> +<%= link_to 'Back', tournament_matches_path %> diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder index a3ef588..fe14010 100644 --- a/app/views/matches/show.json.jbuilder +++ b/app/views/matches/show.json.jbuilder @@ -1 +1 @@ -json.extract! @match, :id, :status, :tournament_id, :name, :winner_id, :created_at, :updated_at +json.extract! @match, :id, :tournament_id, :name, :winner_id, :created_at, :updated_at -- cgit v1.2.3-54-g00ecf
Status Tournament Name Winner
<%= match.status %><%= match.tournament %><%= match.tournament.id %> <%= match.name %> <%= match.winner %><%= link_to 'Show', match %><%= link_to 'Edit', edit_match_path(match) %><%= link_to 'Destroy', match, method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Show', tournament_match_path(@tournament, match) %><%= link_to 'Edit', edit_tournament_match_path(@tournament, match) %><%= link_to 'Destroy', tournament_match_path(@tournament, match), method: :delete, data: { confirm: 'Are you sure?' } %>