mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-03 05:27:25 +00:00
Added manual pool order button
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class WeightsController < ApplicationController
|
||||
before_action :set_weight, only: [:show, :edit, :update, :destroy,:re_gen]
|
||||
before_action :check_access, only: [:new,:create,:update,:destroy,:edit, :re_gen]
|
||||
before_action :set_weight, only: [:pool_order, :show, :edit, :update, :destroy,:re_gen]
|
||||
before_action :check_access, only: [:pool_order, :new,:create,:update,:destroy,:edit, :re_gen]
|
||||
|
||||
|
||||
# GET /weights/1
|
||||
@@ -78,6 +78,21 @@ class WeightsController < ApplicationController
|
||||
GenerateTournamentMatches.new(@tournament).generateWeight(@weight)
|
||||
end
|
||||
|
||||
def pool_order
|
||||
pool = params[:pool_to_order].to_i
|
||||
if @weight.all_pool_matches_finished(pool)
|
||||
PoolOrder.new(@weight.wrestlers_in_pool(pool)).getPoolOrder
|
||||
respond_to do |format|
|
||||
format.html { redirect_to @tournament, notice: "Pool #{pool} placing is updating for weight class #{@weight.max}." }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { redirect_to @tournament, notice: "Pool #{pool} for weight class #{@weight.max} still has matches to finish." }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_weight
|
||||
|
||||
@@ -58,7 +58,7 @@ li:first-child,li:last-child {
|
||||
}
|
||||
</style>
|
||||
<% cache ["#{@weight.id}_bracket", @weight] do %>
|
||||
<table class='smallText'>
|
||||
<table class='smallText'>
|
||||
<h5><strong><%= @tournament.name %> - <%= @weight.max %> lbs Bracket</strong></h5>
|
||||
<tr>
|
||||
<td valign="top" style="padding: 10px;">
|
||||
@@ -71,19 +71,19 @@ li:first-child,li:last-child {
|
||||
|
||||
<td valign="top" style="padding: 10px;">
|
||||
<% if @weight.pool_bracket_type == "twoPoolsToFinal" %>
|
||||
<%= render 'twoPoolFinalBracket' %>
|
||||
<%= render 'twoPoolFinalBracket' %>
|
||||
<% end %>
|
||||
<% if @weight.pool_bracket_type == "twoPoolsToSemi" %>
|
||||
<%= render 'twoPoolSemiBracket' %>
|
||||
<%= render 'twoPoolSemiBracket' %>
|
||||
<% end %>
|
||||
<% if @weight.pool_bracket_type == "fourPoolsToQuarter" %>
|
||||
<%= render 'fourPoolQuarterBracket' %>
|
||||
<%= render 'fourPoolQuarterBracket' %>
|
||||
<% end %>
|
||||
<% if @weight.pool_bracket_type == "eightPoolsToQuarter" %>
|
||||
<%= render 'fourPoolQuarterBracket' %>
|
||||
<% end %>
|
||||
<% if @weight.pool_bracket_type == "fourPoolsToSemi" %>
|
||||
<%= render 'fourPoolSemiBracket' %>
|
||||
<%= render 'fourPoolSemiBracket' %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -91,22 +91,20 @@ li:first-child,li:last-child {
|
||||
<% end %>
|
||||
|
||||
<% if can? :manage, @tournament %>
|
||||
<br><br>
|
||||
<h3>Swap Bracket Position</h3>
|
||||
<%= form_for(Wrestler.new, url: swap_wrestlers_path(@tournament)) do |f| %>
|
||||
<div class="field">
|
||||
<%= f.label 'Wrestler 1' %><br>
|
||||
<%= f.collection_select :originalId, @weight.wrestlers, :id, :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label 'Wrestler 2' %><br>
|
||||
<%= f.collection_select :swapId, @weight.wrestlers, :id, :name %>
|
||||
</div>
|
||||
<br>
|
||||
<%= submit_tag "Swap", :class=>"btn btn-success"%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if can? :manage, @tournament %>
|
||||
<br><br>
|
||||
<h3>Swap Bracket Position</h3>
|
||||
<%= form_for(Wrestler.new, url: swap_wrestlers_path(@tournament)) do |f| %>
|
||||
<div class="field">
|
||||
<%= f.label 'Wrestler 1' %><br>
|
||||
<%= f.collection_select :originalId, @weight.wrestlers, :id, :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label 'Wrestler 2' %><br>
|
||||
<%= f.collection_select :swapId, @weight.wrestlers, :id, :name %>
|
||||
</div>
|
||||
<br>
|
||||
<%= submit_tag "Swap", :class=>"btn btn-success"%>
|
||||
<% end %>
|
||||
<br><br>
|
||||
<h3>Move wrestler to pool with a bye</h3>
|
||||
<%= form_tag '/wrestlers/update_pool' do %>
|
||||
@@ -121,4 +119,15 @@ li:first-child,li:last-child {
|
||||
<br>
|
||||
<%= submit_tag "Move", :class=>"btn btn-success"%>
|
||||
<% end %>
|
||||
<br><br>
|
||||
<h3>Rerun getting pool order</h3>
|
||||
<p>If you changed the result of a match that changes the ranking of a pool.</p>
|
||||
<%= form_tag "/weights/#{@weight.id}/pool_order", :method => :post do %>
|
||||
<div class="field">
|
||||
<%= label_tag 'Pool to order' %><br>
|
||||
<%= select_tag :pool_to_order, options_for_select((1..@weight.pools).step(1).to_a) %>
|
||||
</div>
|
||||
<br>
|
||||
<%= submit_tag "Get Pool Order", :class=>"btn btn-success"%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user