mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-03 21:33:48 +00:00
Added a bout board
This commit is contained in:
@@ -8,7 +8,8 @@ class StaticPagesController < ApplicationController
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
end
|
||||
if @tournament
|
||||
@matches = @tournament.matches
|
||||
@matches = @tournament.matches.where(mat_id: nil)
|
||||
@mats = @tournament.mats
|
||||
if @matches.empty?
|
||||
redirect_to "/static_pages/noMatches?tournament=#{@tournament.id}"
|
||||
end
|
||||
|
||||
@@ -23,6 +23,7 @@ module GeneratesTournamentMatches
|
||||
def generateMatches
|
||||
assignBouts
|
||||
assignLoserNames
|
||||
assignFirstMatchesToMats
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
class Mat < ActiveRecord::Base
|
||||
belongs_to :tournament
|
||||
has_many :matches
|
||||
|
||||
def assignNextMatch
|
||||
t_matches = tournament.matches.where(mat_id: nil)
|
||||
match = t_matches.order(:bout_number).first
|
||||
match.mat_id = self.id
|
||||
match.save
|
||||
end
|
||||
|
||||
def unfinishedMatches
|
||||
matches.where(finished: nil).order(:bout_number)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Match < ActiveRecord::Base
|
||||
belongs_to :tournament
|
||||
belongs_to :weight
|
||||
belongs_to :mat
|
||||
|
||||
|
||||
WIN_TYPES = ["Decision", "Major", "Tech Fall", "Pin", "Forfeit", "Injury Default", "Default", "DQ"]
|
||||
|
||||
@@ -40,5 +40,13 @@ class Tournament < ActiveRecord::Base
|
||||
m.save!
|
||||
end
|
||||
end
|
||||
|
||||
def assignFirstMatchesToMats
|
||||
until mats.order(:id).last.matches.count == 4
|
||||
mats.order(:id).each do |m|
|
||||
m.assignNextMatch
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -4,11 +4,45 @@
|
||||
$('#matchList').dataTable();
|
||||
} );
|
||||
</script>
|
||||
<script>
|
||||
setTimeout("location.reload(true);",30000);
|
||||
</script>
|
||||
<br>
|
||||
<br>
|
||||
<h5 style="color:red">This page reloads every 30s</h5>
|
||||
<br>
|
||||
<br>
|
||||
<h3>Upcoming Matches</h3>
|
||||
<br>
|
||||
<br>
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Mat</th>
|
||||
<th>On Mat</th>
|
||||
<th>On Deck</th>
|
||||
<th>In The Hole</th>
|
||||
<th>Warm Up</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @mats.each.map do |m| %>
|
||||
<tr>
|
||||
<td>Mat <%= m.name %></td>
|
||||
<td><%=m.unfinishedMatches.first.bout_number%><br><%= m.unfinishedMatches.first.w1_name %> vs. <%= m.unfinishedMatches.first.w2_name %></td>
|
||||
<td><%=m.unfinishedMatches.second.bout_number%><br><%= m.unfinishedMatches.second.w1_name %> vs. <%= m.unfinishedMatches.second.w2_name %></td>
|
||||
<td><%=m.unfinishedMatches.third.bout_number%><br><%= m.unfinishedMatches.third.w1_name %> vs. <%= m.unfinishedMatches.third.w2_name %></td>
|
||||
<td><%=m.unfinishedMatches.fourth.bout_number%><br><%= m.unfinishedMatches.fourth.w1_name %> vs. <%= m.unfinishedMatches.fourth.w2_name %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<br>
|
||||
<h3>Matches not assigned</h3>
|
||||
<br>
|
||||
<br>
|
||||
<table class="display compact cell-border" id="matchList">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user