summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-04-27 14:22:17 -0400
committerAndrewMurrell <amurrel@purdue.edu>2014-04-27 14:22:17 -0400
commit442146c7160b95d452975336dfddaf8faf74d544 (patch)
treef4cbb6405a05e0ebbdea264dbcb6124ad96f560d /app/controllers
parentabf98c279674c172fc9064e5013087c72101fad9 (diff)
fixed, seeds, roundrobin, and _show_tourn
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/tournaments_controller.rb23
1 files changed, 7 insertions, 16 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 8752298..c212273 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -15,7 +15,8 @@ class TournamentsController < ApplicationController
when 0
render action: 'show'
when 1
- redirect_to tournament_matches_path(@tournament)
+ #redirect_to tournament_matches_page(@tournament)
+ redirect_to "/tournaments/" + @tournament.id.to_s + "/matches"
when 2
redirect_to tournaments_page
end
@@ -50,20 +51,11 @@ class TournamentsController < ApplicationController
ok &= @tournament.update(tournament_setting_params)
ok &= @tournament.hosts.push(current_user)
for i in 1..(params[:num_stages].to_i) do
- begin
- ok &= @tournament.stages.create(tournament_stage_params(i))
- rescue ActionController::ParameterMissing => e
- ok = false
- @tournament.errors.add("stages[#{i}]", "Stage #{i} not set")
- end
+ ok &= @tournament.stages.create(tournament_stage_params(i))
end
end
- rescue ActiveRecord::RecordNotUnique => e
- ok = false
- @tournament.errors.add(:name, "must be unique")
- rescue => e
+ rescue
ok = false
- @tournament.errors.add(:exception, "Unknown error: ``#{e.class.name}'' -- #{e.inspect} -- #{e.methods - Object.new.methods}")
end
respond_to do |format|
if ok
@@ -134,7 +126,7 @@ class TournamentsController < ApplicationController
ActiveRecord::Base.transaction do
success &= @tournament.save &&
sched = tournament_attribute_params[:type_opt]
- success &= @tournament.stages.create(scheduling: sched)
+ success &= @tournament.stages.create(scheduling_method: sched)
success &= @tournament.stages.first.create_matches
end
if success
@@ -179,9 +171,8 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_attribute_params
- params[:num_stages] ||= 1
if params[:tournament]
- p = params.require(:tournament).permit(:game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :sampling_method, :scoring_method)
+ p = params.require(:tournament).permit(:game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method, :scoring_method)
if p[:game_id]
game = Game.find(p[:game_id])
p[:min_players_per_team] ||= game.min_players_per_team
@@ -207,7 +198,7 @@ class TournamentsController < ApplicationController
end
def tournament_stage_params(i)
- params.require(:tournament).require(:stages).require(i.to_s).permit(:scheduling_method, :seeding_method)
+ params.require(:tournament).require(i.to_sym).permit(:scheduling_method, :seeding_method)
end
def is_owner?(object)