diff --git a/app/controllers/weights_controller.rb b/app/controllers/weights_controller.rb index 173186e..77b63b5 100644 --- a/app/controllers/weights_controller.rb +++ b/app/controllers/weights_controller.rb @@ -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 diff --git a/app/views/tournaments/bracket.html.erb b/app/views/tournaments/bracket.html.erb index 0899194..980cd3d 100644 --- a/app/views/tournaments/bracket.html.erb +++ b/app/views/tournaments/bracket.html.erb @@ -58,7 +58,7 @@ li:first-child,li:last-child { } <% cache ["#{@weight.id}_bracket", @weight] do %> -
| @@ -71,19 +71,19 @@ li:first-child,li:last-child { | <% 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 %> |