diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index 291ad7c..3186ad8 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -16,6 +16,8 @@ class MatchesController < ApplicationController
if @match
@w1 = @match.wrestler1
@w2 = @match.wrestler2
+ @wrestlers = [@w1,@w2]
+ @tournament = @match.tournament
end
end
@@ -43,7 +45,7 @@ class MatchesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def match_params
- params.require(:match).permit(:w1, :w2, :g_stat, :r_stat, :winner_id, :win_type, :score, :finished)
+ params.require(:match).permit(:w1, :w2, :w1_stat, :w2_stat, :winner_id, :win_type, :score, :finished)
end
def check_access
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index b96e8b4..dcb9849 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -1,8 +1,17 @@
class TournamentsController < ApplicationController
- before_action :set_tournament, only: [:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets]
- before_filter :check_access, only: [:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:destroy,:generate_matches]
+ before_action :set_tournament, only: [:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets]
+ before_filter :check_access, only: [:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:destroy,:generate_matches,:matches]
before_filter :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
+ def matches
+ @matches = @tournament.matches.sort_by{|m| m.bout_number}
+ if @match
+ @w1 = @match.wrestler1
+ @w2 = @match.wrestler2
+ @wrestlers = [@w1,@w2]
+ end
+ end
+
def weigh_in_weight
if params[:wrestler]
Wrestler.update(params[:wrestler].keys, params[:wrestler].values)
diff --git a/app/views/layouts/_lsidebar.html.erb b/app/views/layouts/_lsidebar.html.erb
index 2e80917..7b2ef6b 100644
--- a/app/views/layouts/_lsidebar.html.erb
+++ b/app/views/layouts/_lsidebar.html.erb
@@ -6,7 +6,7 @@
Tournament Links
-
+ <%= link_to "Tournament home" , "/tournaments/#{@tournament.id}/" %>
<%= link_to "Brackets" , "/tournaments/#{@tournament.id}/brackets" %>
<%= link_to "Upcoming Matches" , "/tournaments/#{@tournament.id}/up_matches" %>
<%= link_to "Team Scores" , "/tournaments/#{@tournament.id}/team_scores" %>
@@ -19,6 +19,7 @@
Pages
<%= link_to "Weigh In Page" , "/tournaments/#{@tournament.id}/weigh_in" %>
+ <%= link_to "All Matches" , "/tournaments/#{@tournament.id}/matches" %>
Time Savers
<%= link_to "Create High School Weights" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=hs",data: { confirm: 'Are you sure? This will delete all current weights.' } %>
diff --git a/app/views/matches/_edit_form.html.erb b/app/views/matches/_edit_form.html.erb
deleted file mode 100644
index d66515b..0000000
--- a/app/views/matches/_edit_form.html.erb
+++ /dev/null
@@ -1,36 +0,0 @@
-<%= form_for(@match) do |f| %>
- <% if @match.errors.any? %>
-
-
<%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:
-
-
- <% @match.errors.full_messages.each do |msg| %>
- <%= msg %>
- <% end %>
-
-
- <% end %>
-
-
- <%= f.label "Win Type" %>
- <%= f.select(:win_type, Match::WIN_TYPES) %>
-
-
- <%= f.label "Winner" %> Please put in the id of the winner
- <%= @w1.name %> ID: <%= @w1.id %>
- <%= @w2.name %> ID: <%= @w2.id %>
- <%= f.number_field :winner_id %>
-
-
- <%= f.label "Score" %> Also put pin time here if applicable. If default or forfeit, leave blank
- <%= f.text_field :score %>
-
-
- <%= f.hidden_field :finished, :value => 1 %>
- <%= f.hidden_field :round, :value => @match.round %>
-
-
-
- <%= f.submit %>
-
-<% end %>
diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb
index 55ac453..d5dd506 100644
--- a/app/views/matches/_form.html.erb
+++ b/app/views/matches/_form.html.erb
@@ -10,36 +10,219 @@
<% end %>
-
+ Bout <%= @match.bout_number %>
+
+
+
+ <%= @w1.name %>
+ Green
+ Red
+ Last Match: <%= if @w1.lastMatch != nil then time_ago_in_words(@w1.lastMatch.updated_at) end%>
+ <%= @w2.name %>
+ Red
+ Green
+ Last Match: <%= if @w2.lastMatch != nil then time_ago_in_words(@w2.lastMatch.updated_at) end%>
+
+
+
+
+ <%= @w1.name %> Stats: <%= f.text_area :w1_stat, cols: "30", rows: "10" %>
+ <%= @w2.name %> Stats: <%= f.text_area :w2_stat, cols: "30", rows: "10" %>
+
+
+ <%= @w1.name %> Scoring T2
+ E1
+ R2
+ N2
+ N3
+ N4
+ P1
+ <%= @w2.name %> Scoring T2
+ E1
+ R2
+ N2
+ N3
+ N4
+ P1
+
+
+ <%= @w1.name %> Choice Chose Top
+ Chose Bottom
+ Chose Nuetral
+ Differed
+ <%= @w2.name %> Choice Chose Top
+ Chose Bottom
+ Chose Nuetral
+ Differed
+
+
+ <%= @w1.name %> Warnings Stalling
+ Caution
+ <%= @w2.name %> Warnings Stalling
+ Caution
+
+
+ Match Options End Period
+
+
+
+
+
+
+Match Results
+
- <%= f.label :w1_name %>
- <%= f.number_field :w1_name %>
+ <%= f.label "Win Type" %>
+ <%= f.select(:win_type, Match::WIN_TYPES) %>
+
- <%= f.label :w2_name %>
- <%= f.number_field :w2_name %>
+ <%= f.label "Winner" %> Please choose the winner
+ <%= f.collection_select :winner_id, @wrestlers, :id, :name %>
+
- <%= f.label :g_stat %>
- <%= f.text_area :g_stat %>
-
-
- <%= f.label :r_stat %>
- <%= f.text_area :r_stat %>
-
-
- <%= f.label :winner_id %>
- <%= f.number_field :winner_id %>
-
-
- <%= f.label :win_type %>
- <%= f.text_field :win_type %>
-
-
- <%= f.label :score %>
+ <%= f.label "Final Score" %> Also put pin time here if applicable. If default or forfeit, leave blank. Example: 7-2, 17-2, or 2:34
<%= f.text_field :score %>
+
+
+ <%= f.hidden_field :finished, :value => 1 %>
+ <%= f.hidden_field :round, :value => @match.round %>
+
+
+
- <%= f.submit %>
+ <%= f.submit onclick: "return confirm('Is the name of the winner ' + document.getElementById('match_winner_id').options[document.getElementById('match_winner_id').selectedIndex].text + '?')", :class=>"btn btn-success" %>
+
<% end %>
+
+
diff --git a/app/views/matches/edit.html.erb b/app/views/matches/edit.html.erb
index a64773b..4540c95 100644
--- a/app/views/matches/edit.html.erb
+++ b/app/views/matches/edit.html.erb
@@ -1,5 +1,6 @@
+<%= link_to "Back to #{@match.tournament.name} matches", "/tournaments/#{@match.tournament.id}/matches", :class=>"btn btn-default" %>
+
+
<%= @w1.name %> VS. <%= @w2.name %>
-<%= render 'edit_form' %>
-
-<%= link_to 'Back', root_path %>
+<%= render 'form' %>
diff --git a/app/views/tournaments/matches.html.erb b/app/views/tournaments/matches.html.erb
new file mode 100644
index 0000000..a2a01b1
--- /dev/null
+++ b/app/views/tournaments/matches.html.erb
@@ -0,0 +1,37 @@
+
+
+All <%= @tournament.name %> matches
+
+
+<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
+
+
+
+
+
+
+ Bout number
+ Matchup
+ Finished?
+
+
+
+
+
+ <% @matches.each do |match| %>
+
+ <%= match.bout_number %>
+ <%= match.w1_name %> vs <%= match.w2_name %>
+ <%= match.finished %>
+ <%= link_to 'Show', match, :class=>"btn btn-default" %>
+ <%= link_to 'Edit', edit_match_path(match), :class=>"btn btn-primary" %>
+
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 5ad9ab4..d98061e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -39,6 +39,7 @@ Wrestling::Application.routes.draw do
get 'tournaments/:id/team_scores' => 'tournaments#team_scores'
get 'tournaments/:id/up_matches' => 'tournaments#up_matches'
get 'tournaments/:id/no_matches' => 'tournaments#no_matches'
+ get 'tournaments/:id/matches' => 'tournaments#matches'
# Example of regular route:
# get 'products/:id' => 'catalog#view'