From 1c5930a82f80abff26556e85c71834af9803bc7c Mon Sep 17 00:00:00 2001 From: tkimia Date: Mon, 28 Apr 2014 20:30:40 -0400 Subject: bracket changes to status 2 --- app/controllers/brackets_controller.rb | 4 ++-- app/views/common/_show_tournament.html.erb | 2 +- db/seeds.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/brackets_controller.rb b/app/controllers/brackets_controller.rb index 50ff5fe..ac34bfe 100644 --- a/app/controllers/brackets_controller.rb +++ b/app/controllers/brackets_controller.rb @@ -37,7 +37,7 @@ class BracketsController < ApplicationController @bracket.name = current_user.user_name + "'s Prediction for " + @tournament.name respond_to do |format| - if @tournament.status == 1 && @tournament.stages.first.scheduling_method == "elimination" && @tournament.stages.first.matches.first.status == 0 + if @tournament.status == 1 && @tournament.stages.first.scheduling_method == "elimination" && @tournament.stages.first.matches.first.status < 2 @bracket.save @bracket.create_matches format.html { redirect_to @bracket, notice: 'Bracket was successfully created.' } @@ -54,7 +54,7 @@ class BracketsController < ApplicationController def update respond_to do |format| if @bracket.update(bracket_params) - format.html { redirect_to @bracket, notice: 'Bracket was successfully updated.' } + format.html { redirect_to @tournament, notice: 'Bracket was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } diff --git a/app/views/common/_show_tournament.html.erb b/app/views/common/_show_tournament.html.erb index 826eeaa..02852cf 100644 --- a/app/views/common/_show_tournament.html.erb +++ b/app/views/common/_show_tournament.html.erb @@ -33,7 +33,7 @@ <% elsif target.players.include?(current_user)%>

You've signed up for this tournament!

<% end %> - <% if target.status == 1 && target.stages.first.scheduling_method == "elimination" && target.stages.first.matches.first.status == 0 %> + <% if target.status == 1 && target.stages.order(:id).first.scheduling_method == "elimination" && target.stages.order(:id).first.matches.order(:id).first.status < 2 %> <%= form_tag(tournament_brackets_path(target), method: "post") do %> <%= submit_tag("Make Bracket") %> <% end %> diff --git a/db/seeds.rb b/db/seeds.rb index c648053..c3b9beb 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -123,7 +123,7 @@ if Rails.env.development? players_for_league.each do |player| tourn5.join(player) end - tourn5.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding") + tourn5.stages.create(scheduling_method: "elimination" , seeding_method: "random_seeding") # Yet another League tournament tourn6 = Tournament.create(game_id: 1, name: "3 teams per match", -- cgit v1.2.3