1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added team abbreviation

This commit is contained in:
2019-01-24 20:16:43 +00:00
parent 0599faa173
commit 6bbb0b2e2c
11 changed files with 94 additions and 59 deletions

View File

@@ -99,6 +99,23 @@ class Match < ActiveRecord::Base
self.loser2_name
end
end
def w1_bracket_name
if self.w1 != nil
return "#{w1_name} (#{wrestler1.school.abbreviation})"
else
""
end
end
def w2_bracket_name
if self.w2 != nil
return "#{w2_name} (#{wrestler2.school.abbreviation})"
else
""
end
end
def winner_name
if self.finished != 1
return ""
@@ -110,6 +127,15 @@ class Match < ActiveRecord::Base
return self.w2_name
end
end
def bracket_winner_name
if winner_name != ""
return "#{winner_name} (#{Wrestler.find(winner_id).school.abbreviation})"
else
""
end
end
def weight_max
self.weight.max
end

View File

@@ -12,6 +12,15 @@ class School < ActiveRecord::Base
self.tournament.destroy_all_matches
end
def abbreviation
name_array = self.name.split(' ')
if name_array.size > 1
return "#{name_array[0].chars.to_a.first}#{name_array[1].chars.to_a[0..1].join('').upcase}"
else
return "#{name_array[0].chars.to_a[0..2].join('').upcase}"
end
end
#calculate score here
def page_score_string
if self.score == nil

View File

@@ -1,11 +1,11 @@
<h4>Bout: <%= @match.bout_number %></h4>
<h4>Weight Class: <%= @match.wrestler1.weight.max %></h4>
<h4>Weight Class: <%= @match.weight.max %></h4>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th></th>
<th><%= @match.wrestler1.name %> (<%= @match.wrestler1.school.name %>)</th>
<th><%= @match.wrestler2.name %> (<%= @match.wrestler2.school.name %>)</th>
<th><%= @match.w1_name %> <%= "- #{@match.wrestler1.school.name}" if @match.wrestler1 %></th>
<th><%= @match.w2_name %> <%= "- #{@match.wrestler2.school.name}" if @match.wrestler2 %></th>
</tr>
</thead>

View File

@@ -4,9 +4,9 @@
<% @matches.select{|m|m.bracket_position == "Quarter"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -16,9 +16,9 @@
<% @matches.select{|m|m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
<% end %>
@@ -27,9 +27,9 @@
<% @matches.select{|m|m.bracket_position == "1/2"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -37,7 +37,7 @@
<ul class="round round-4">
<li>&nbsp;</li>
<li class="bracket-winner"><%= match.winner_name %> <span></span></li>
<li class="bracket-winner"><%= match.bracket_winner_name %> <span></span></li>
1st
<li>&nbsp;</li>
@@ -50,9 +50,9 @@
<% @matches.select{|m|m.bracket_position == "3/4"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -60,7 +60,7 @@
<ul class="round round-2">
<li>&nbsp;</li>
<li class="bracket-winner"> <%= match.winner_name %><span></span></li>
<li class="bracket-winner"> <%= match.bracket_winner_name %><span></span></li>
3rd
<li>&nbsp;</li>
@@ -73,9 +73,9 @@
<% @matches.select{|m|m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -85,9 +85,9 @@
<% @matches.select{|m|m.bracket_position == "5/6"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -95,7 +95,7 @@
<ul class="round round-3">
<li>&nbsp;</li>
<li class="bracket-winner"> <%= match.winner_name %><span></span></li>
<li class="bracket-winner"> <%= match.bracket_winner_name %><span></span></li>
5th
<li>&nbsp;</li>
@@ -108,9 +108,9 @@
<% @matches.select{|m|m.bracket_position == "7/8"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -118,7 +118,7 @@
<ul class="round round-2">
<li>&nbsp;</li>
<li class="bracket-winner"><%= match.winner_name %> <span></span></li>
<li class="bracket-winner"><%= match.bracket_winner_name %> <span></span></li>
7th
<li>&nbsp;</li>

View File

@@ -4,9 +4,9 @@
<% @matches.select{|m|m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -16,9 +16,9 @@
<% @matches.select{|m|m.bracket_position == "1/2"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -26,7 +26,7 @@
<ul class="round round-3">
<li>&nbsp;</li>
<li class="bracket-winner"><%= match.winner_name %><span></span></li>
<li class="bracket-winner"><%= match.bracket_winner_name %><span></span></li>
1st
<li>&nbsp;</li>
@@ -40,9 +40,9 @@
<% @matches.select{|m|m.bracket_position == "3/4"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -50,7 +50,7 @@
<ul class="round round-2">
<li>&nbsp;</li>
<li class="bracket-winner"><%= match.winner_name %><span></span></li>
<li class="bracket-winner"><%= match.bracket_winner_name %><span></span></li>
3rd
<li>&nbsp;</li>
@@ -65,9 +65,9 @@
<% @matches.select{|m|m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -77,9 +77,9 @@
<% @matches.select{|m|m.bracket_position == "5/6"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -87,7 +87,7 @@
<ul class="round round-3">
<li>&nbsp;</li>
<li class="bracket-winner"><%= match.winner_name %><span></span></li>
<li class="bracket-winner"><%= match.bracket_winner_name %><span></span></li>
5th
<li>&nbsp;</li>
@@ -100,9 +100,9 @@
<% @matches.select{|m|m.bracket_position == "7/8"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -110,7 +110,7 @@
<ul class="round round-2">
<li>&nbsp;</li>
<li class="bracket-winner"><%= match.winner_name %><span></span></li>
<li class="bracket-winner"><%= match.bracket_winner_name %><span></span></li>
7th
<li>&nbsp;</li>

View File

@@ -17,7 +17,7 @@
<tbody>
<% @wrestlers.select{|w| w.pool == @pool}.sort_by{|w| w.bracket_line}.each do |w| %>
<tr>
<td><%= w.original_seed %> <%= w.name %> <%= w.season_win %>-<%= w.season_loss %> <%= w.school.name %></td>
<td><%= w.original_seed %> <%= w.name %> - <%= w.school.name %></td>
<% @round = 1 %>
<% until @matches.select{|m| m.round == @round}.blank? %>
<% if @round <= @pools %>

View File

@@ -4,9 +4,9 @@
<% @matches.select{|m|m.bracket_position == "1/2"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -14,7 +14,7 @@
<ul class="round round-2">
<li>&nbsp;</li>
<li class="bracket-winner"><%= match.winner_name %><span></span></li>
<li class="bracket-winner"><%= match.bracket_winner_name %><span></span></li>
1st
<li>&nbsp;</li>
@@ -27,9 +27,9 @@
<% @matches.select{|m|m.bracket_position == "3/4"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -37,7 +37,7 @@
<ul class="round round-2">
<li>&nbsp;</li>
<li class="bracket-winner"><%= match.winner_name %> <span></span></li>
<li class="bracket-winner"><%= match.bracket_winner_name %> <span></span></li>
3rd
<li>&nbsp;</li>

View File

@@ -4,9 +4,9 @@
<% @matches.select{|m|m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -16,9 +16,9 @@
<% @matches.select{|m|m.bracket_position == "1/2"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -26,7 +26,7 @@
<ul class="round round-3">
<li>&nbsp;</li>
<li class="bracket-winner"><%= match.winner_name %><span></span></li>
<li class="bracket-winner"><%= match.bracket_winner_name %><span></span></li>
1st
<li>&nbsp;</li>
@@ -40,9 +40,9 @@
<% @matches.select{|m|m.bracket_position == "3/4"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
@@ -50,7 +50,7 @@
<ul class="round round-2">
<li>&nbsp;</li>
<li class="bracket-winner"><%= match.winner_name %><span></span></li>
<li class="bracket-winner"><%= match.bracket_winner_name %><span></span></li>
3rd
<li>&nbsp;</li>

View File

@@ -24,7 +24,7 @@
<tr>
<td><%= match.bout_number %></td>
<td><%= match.bracket_position %></td>
<td><%= match.w1_name %> vs <%= match.w2_name %></td>
<td><%= match.w1_bracket_name %> vs <%= match.w2_bracket_name %></td>
<td><%= match.finished %></td>
<td><%= link_to 'Show', match, :class=>"btn btn-default btn-sm" %>
<%= link_to 'Edit', edit_match_path(match), :class=>"btn btn-primary btn-sm" %>

View File

@@ -12,7 +12,7 @@
<tbody>
<% @schools.each do |school| %>
<tr>
<td><%= school.name %></td>
<td><%= school.name %> (<%= school.abbreviation %>)</td>
<td><%= school.page_score_string %></td>
</tr>
<% end %>

View File

@@ -28,10 +28,10 @@
<% @mats.each.map do |m| %>
<tr>
<td><%= m.name %></td>
<td><% if m.unfinished_matches.first %><strong><%=m.unfinished_matches.first.bout_number%></strong> - <%= m.unfinished_matches.first.weight_max %> lbs<br><%= m.unfinished_matches.first.w1_name %> vs. <%= m.unfinished_matches.first.w2_name %><% end %></td>
<td><% if m.unfinished_matches.second %><strong><%=m.unfinished_matches.second.bout_number%></strong> - <%= m.unfinished_matches.second.weight_max %> lbs<br><%= m.unfinished_matches.second.w1_name %> vs. <%= m.unfinished_matches.second.w2_name %><% end %></td>
<td><% if m.unfinished_matches.third %><strong><%=m.unfinished_matches.third.bout_number%></strong> - <%= m.unfinished_matches.third.weight_max %> lbs<br><%= m.unfinished_matches.third.w1_name %> vs. <%= m.unfinished_matches.third.w2_name %><% end %></td>
<td><% if m.unfinished_matches.fourth %><strong><%=m.unfinished_matches.fourth.bout_number%></strong> - <%= m.unfinished_matches.fourth.weight_max %> lbs<br><%= m.unfinished_matches.fourth.w1_name %> vs. <%= m.unfinished_matches.fourth.w2_name %><% end %></td>
<td><% if m.unfinished_matches.first %><strong><%=m.unfinished_matches.first.bout_number%></strong> - <%= m.unfinished_matches.first.weight_max %> lbs<br><%= m.unfinished_matches.first.w1_bracket_name %> vs. <%= m.unfinished_matches.first.w2_bracket_name %><% end %></td>
<td><% if m.unfinished_matches.second %><strong><%=m.unfinished_matches.second.bout_number%></strong> - <%= m.unfinished_matches.second.weight_max %> lbs<br><%= m.unfinished_matches.second.w1_bracket_name %> vs. <%= m.unfinished_matches.second.w2_bracket_name %><% end %></td>
<td><% if m.unfinished_matches.third %><strong><%=m.unfinished_matches.third.bout_number%></strong> - <%= m.unfinished_matches.third.weight_max %> lbs<br><%= m.unfinished_matches.third.w1_bracket_name %> vs. <%= m.unfinished_matches.third.w2_bracket_name %><% end %></td>
<td><% if m.unfinished_matches.fourth %><strong><%=m.unfinished_matches.fourth.bout_number%></strong> - <%= m.unfinished_matches.fourth.weight_max %> lbs<br><%= m.unfinished_matches.fourth.w1_bracket_name %> vs. <%= m.unfinished_matches.fourth.w2_bracket_name %><% end %></td>
</tr>
<% end %>
</tbody>
@@ -56,7 +56,7 @@
<td>Round <%= m.round %></td>
<td><%= m.bout_number %></td>
<td><%= m.weight_max %> lbs</td>
<td><%= m.w1_name %> vs. <%= m.w2_name %></td>
<td><%= m.w1_bracket_name %> vs. <%= m.w2_bracket_name %></td>
</tr>
<% end %>
<% end %>