From 7183935b606d257d6c6b81275dd69056eda01a8e Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Tue, 3 Feb 2015 15:06:02 -0500 Subject: [PATCH] Created 4 pool view without bracket. --- app/controllers/static_pages_controller.rb | 22 +----- app/models/wrestler.rb | 12 ++- app/views/static_pages/_fourPool.html.erb | 90 ++++++++++++++++++++++ app/views/static_pages/_man5.html.erb | 57 -------------- app/views/static_pages/brackets.html.erb | 36 ++------- 5 files changed, 110 insertions(+), 107 deletions(-) create mode 100644 app/views/static_pages/_fourPool.html.erb delete mode 100644 app/views/static_pages/_man5.html.erb diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index e9265c6..ac6f381 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -25,24 +25,10 @@ class StaticPagesController < ApplicationController if params[:weight] @weight = Weight.find(params[:weight]) @tournament = Tournament.find(@weight.tournament_id) - @wrestlers = Wrestler.where(weight_id: @weight.id) - @bracket_size = Wrestler.where(weight_id: @weight.id).count - @seed1 = Wrestler.where(weight_id: @weight.id, original_seed: 1).first - @seed10 = Wrestler.where(weight_id: @weight.id, original_seed: 10).first - @seed7 = Wrestler.where(weight_id: @weight.id, original_seed: 7).first - @seed5 = Wrestler.where(weight_id: @weight.id, original_seed: 5).first - @seed4 = Wrestler.where(weight_id: @weight.id, original_seed: 4).first - @seed2 = Wrestler.where(weight_id: @weight.id, original_seed: 2).first - @seed9 = Wrestler.where(weight_id: @weight.id, original_seed: 9).first - @seed6 = Wrestler.where(weight_id: @weight.id, original_seed: 6).first - @seed8 = Wrestler.where(weight_id: @weight.id, original_seed: 8).first - @seed3 = Wrestler.where(weight_id: @weight.id, original_seed: 3).first - @seed11 = Wrestler.where(weight_id: @weight.id, original_seed: 11).first - @seed12 = Wrestler.where(weight_id: @weight.id, original_seed: 12).first - @seed13 = Wrestler.where(weight_id: @weight.id, original_seed: 13).first - @seed14 = Wrestler.where(weight_id: @weight.id, original_seed: 14).first - @seed15 = Wrestler.where(weight_id: @weight.id, original_seed: 15).first - @seed16 = Wrestler.where(weight_id: @weight.id, original_seed: 16).first + @poolOneWrestlers = Wrestler.where(weight_id: @weight.id, poolNumber: 1) + @poolTwoWrestlers = Wrestler.where(weight_id: @weight.id, poolNumber: 2) + @poolThreeWrestlers = Wrestler.where(weight_id: @weight.id, poolNumber: 3) + @poolFourWrestlers = Wrestler.where(weight_id: @weight.id, poolNumber: 4) end diff --git a/app/models/wrestler.rb b/app/models/wrestler.rb index 4613daf..28fac50 100644 --- a/app/models/wrestler.rb +++ b/app/models/wrestler.rb @@ -1,7 +1,7 @@ class Wrestler < ActiveRecord::Base belongs_to :school belongs_to :weight - attr_accessor :matches_all, :isWrestlingThisRound + attr_accessor :matches_all, :isWrestlingThisRound, :boutByRound def isWrestlingThisRound(matchRound) @gMatches = Match.where(g_id: self.id, round: matchRound) @@ -10,11 +10,19 @@ class Wrestler < ActiveRecord::Base if @gMatches.blank? and @rMatches.blank? return false else - puts "He does wrestle this round" return true end end + def boutByRound(round) + @match = matches_all.select{|m| m.round == round}.first + if @match.blank? + return "BYE" + else + return @match.boutNumber + end + end + def matches_all @gMatches = Match.where(g_id: self.id) @rMatches = Match.where(r_id: self.id) diff --git a/app/views/static_pages/_fourPool.html.erb b/app/views/static_pages/_fourPool.html.erb new file mode 100644 index 0000000..91d51fb --- /dev/null +++ b/app/views/static_pages/_fourPool.html.erb @@ -0,0 +1,90 @@ +
Pool 1
+ + + + + + + + + + + <% @poolOneWrestlers.each do |w| %> + + + + + + + <% end %> + +
NameR1R2R3
<%= w.name %> <%= w.season_win %>-<%= w.season_loss %> <%= w.school.name %><%= w.boutByRound(1) %>
Result
<%= w.boutByRound(2) %><%= w.boutByRound(3) %>
+ + +
Pool 2
+ + + + + + + + + + + <% @poolTwoWrestlers.each do |w| %> + + + + + + + <% end %> + +
NameR1R2R3
<%= w.name %> <%= w.season_win %>-<%= w.season_loss %> <%= w.school.name %><%= w.boutByRound(1) %>
Result
<%= w.boutByRound(2) %><%= w.boutByRound(3) %>
+ + +
Pool 3
+ + + + + + + + + + + <% @poolThreeWrestlers.each do |w| %> + + + + + + + <% end %> + +
NameR1R2R3
<%= w.name %> <%= w.season_win %>-<%= w.season_loss %> <%= w.school.name %><%= w.boutByRound(1) %>
Result
<%= w.boutByRound(2) %><%= w.boutByRound(3) %>
+ + +
Pool 4
+ + + + + + + + + + + <% @poolFourWrestlers.each do |w| %> + + + + + + + <% end %> + +
NameR1R2R3
<%= w.name %> <%= w.season_win %>-<%= w.season_loss %> <%= w.school.name %><%= w.boutByRound(1) %>
Result
<%= w.boutByRound(2) %><%= w.boutByRound(3) %>
\ No newline at end of file diff --git a/app/views/static_pages/_man5.html.erb b/app/views/static_pages/_man5.html.erb deleted file mode 100644 index e6cedcd..0000000 --- a/app/views/static_pages/_man5.html.erb +++ /dev/null @@ -1,57 +0,0 @@ - -

Pool 1

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameR1R2R3R4R5
1. <%= @seed1.name %> <%= @seed1.season_win %>-<%= @seed1.season_loss %> <%= @seed1.school.name %>V2
Result
V3V5V4BYE
2. <%= @seed5.name %> <%= @seed5.season_win %>-<%= @seed5.season_loss %> <%= @seed5.school.name %>V1V5V4BYEV3
3. <%= @seed3.name %> <%= @seed3.season_win %>-<%= @seed3.season_loss %> <%= @seed3.school.name %>V4V1BYEV5V2
4. <%= @seed4.name %> <%= @seed4.season_win %>-<%= @seed4.season_loss %> <%= @seed4.school.name %>V3BYEV2V1V5
5. <%= @seed2.name %> <%= @seed2.season_win %>-<%= @seed2.season_loss %> <%= @seed2.school.name %>BYEV2V1V3V4
- diff --git a/app/views/static_pages/brackets.html.erb b/app/views/static_pages/brackets.html.erb index 618e169..e4f7c69 100644 --- a/app/views/static_pages/brackets.html.erb +++ b/app/views/static_pages/brackets.html.erb @@ -2,34 +2,10 @@

<%= @weight.max %> lbs Bracket

-<% if @bracket_size == 10 %> - <%= render 'man10' %> -<% elsif @bracket_size == 9 %> - <%= render 'man9' %> -<% elsif @bracket_size == 8 %> - <%= render 'man8' %> -<% elsif @bracket_size == 7 %> - <%= render 'man7' %> -<% elsif @bracket_size == 6 %> - <%= render 'man6' %> -<% elsif @bracket_size == 5 %> - <%= render 'man5' %> -<% elsif @bracket_size == 4 %> - <%= render 'man4' %> -<% elsif @bracket_size == 3 %> - <%= render 'man3' %> -<% elsif @bracket_size == 2 %> - <%= render 'man2' %> -<% elsif @bracket_size == 16 %> - <%= render 'man16' %> -<% elsif @bracket_size == 15 %> - <%= render 'man15' %> -<% elsif @bracket_size == 14 %> - <%= render 'man14' %> -<% elsif @bracket_size == 13 %> - <%= render 'man13' %> -<% elsif @bracket_size == 12 %> - <%= render 'man12' %> -<% elsif @bracket_size == 11 %> - <%= render 'man11' %> +<% if @weight.pools == 4 %> + <%= render 'fourPool' %> +<% elsif @weight.pools == 2 %> + <%= render 'twoPool' %> +<% elsif @weight.pools == 1 %> + <%= render 'onePool' %> <% end %> \ No newline at end of file