<% cache ["#{@weight.id}_bracket", @weight] do %>


<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>

<%= @tournament.name %> - <%= @weight.max %> lbs Bracket
<% @matches = @tournament.matches.select{|m| m.weight_id == @weight.id} %> <% @wrestlers = Wrestler.where(weight_id: @weight.id) %> <% @pools = @weight.pool_rounds(@matches) %> <%= render 'pool' %> <% if @weight.pool_bracket_type == "twoPoolsToFinal" %> <%= render 'twoPoolFinalBracket' %> <% end %> <% if @weight.pool_bracket_type == "twoPoolsToSemi" %> <%= render 'twoPoolSemiBracket' %> <% end %> <% if @weight.pool_bracket_type == "fourPoolsToQuarter" %> <%= render 'fourPoolQuarterBracket' %> <% end %> <% if @weight.pool_bracket_type == "eightPoolsToQuarter" %> <%= render 'fourPoolQuarterBracket' %> <% end %> <% if @weight.pool_bracket_type == "fourPoolsToSemi" %> <%= render 'fourPoolSemiBracket' %> <% end %>
<% end %> <% if can? :manage, @tournament %>

Swap Bracket Position

<%= form_for(Wrestler.new, url: swap_wrestlers_path(@tournament)) do |f| %>
<%= f.label 'Wrestler 1' %>
<%= f.collection_select :originalId, @weight.wrestlers, :id, :name %>
<%= f.label 'Wrestler 2' %>
<%= f.collection_select :swapId, @weight.wrestlers, :id, :name %>

<%= submit_tag "Swap", :class=>"btn btn-success"%> <% end %> <% end %> <% if can? :manage, @tournament %>

Move wrestler to pool with a bye

<%= form_tag '/wrestlers/update_pool' do %>
<%= label_tag 'Wrestler to move' %>
<%= collection_select(:wrestler, :id, @weight.wrestlers, :id, :name) %>
<%= label_tag 'Pool to move to' %>
<%= select :wrestler, :pool, @weight.pools_with_bye %>

<%= submit_tag "Move", :class=>"btn btn-success"%> <% end %> <% end %>