diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/matches_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/teams_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/tournaments_controller.rb | 9 |
3 files changed, 8 insertions, 11 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index d7a8b99..59f376a 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -8,12 +8,6 @@ class MatchesController < ApplicationController # GET /tournaments/1/matches # GET /tournaments/1/matches.json def index - @matches = @tournament.matches - # depth of SVG tree - @depth = Math.log2(@matches.count).floor+1; - # height of SVG - @height = 200 * 2**Math.log2(@matches.count).floor + 100; - @h_sector = 2**(@depth-1)+1 end # For compatability with the router assumptions made by ApplicationController#check_permission @@ -250,7 +244,7 @@ class MatchesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def match_params - params.require(:match).permit(:status, :tournament_stage_id, :name, :winner_id, :remote_id, :submitted_peer_evaluations) + params.require(:match).permit(:status, :tournament_stage_id, :winner_id, :remote_id, :submitted_peer_evaluations) end # Turn of check_edit, since our #update is flexible diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index 57ae256..6abc74c 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -68,7 +68,7 @@ class TeamsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def team_params - params.require(:team).permit(:match_id) + params[:team] end def is_owner?(object) diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index b6f911f..4b0e1af 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -96,10 +96,13 @@ class TournamentsController < ApplicationController when "start" check_permission(:edit, @tournament) @tournament.status = 1 - @tournament.save + ok = + @tournament.save && + @tournament.tournament_stages.create(scheduling: "elimination") && + @tournament.tournament_stages.first.create_matches respond_to do |format| - if @tournament.setup - format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } + if ok + format.html { redirect_to @tournament, notice: 'You have started this tournament.' } format.json { head :no_content } else format.html { redirect_to @tournament, notice: "You don't have permission to start this tournament." } |