summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-03-06 22:34:08 -0500
committerAndrewMurrell <amurrel@purdue.edu>2014-03-06 22:34:08 -0500
commit3ce5876375cbb3057ffc96e2886ba57cbd875dc9 (patch)
treee59dc46b293cdcd4ad8ad5b33bd4703f65adb0d9 /app/controllers
parentce8b05ed8fa3466c727269daa47ba7df672fdca1 (diff)
parent70bae69d731afc5300ffa5b176732ebe27d0810f (diff)
Fixed some merge errors in show.html.erb
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/tournaments_controller.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 9e6a6e6..3583ec3 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -38,9 +38,9 @@ class TournamentsController < ApplicationController
# POST /tournaments.json
def create
@tournament = Tournament.new(tournament_params)
-
respond_to do |format|
if @tournament.save
+ @tournament.hosts.push(current_user)
format.html { redirect_to @tournament, notice: 'Tournament was successfully created.' }
format.json { render action: 'show', status: :created, location: @tournament }
else
@@ -53,8 +53,7 @@ class TournamentsController < ApplicationController
# PATCH/PUT /tournaments/1
# PATCH/PUT /tournaments/1.json
def update
- require 'pp'
- pp params
+
if params[:update_action].nil?
check_perms
respond_to do |format|
@@ -77,8 +76,15 @@ class TournamentsController < ApplicationController
format.html { render action: 'permission_denied', status: :forbidden }
format.json { render json: "Permission denied", status: :forbidden }
end
- #when "open"
- # TODO
+ when "open"
+ respond_to do |format|
+ if @tournament.setup
+ format.html { render action: 'show', notice: 'You have joined this tournament.' }
+ format.json { head :no_content }
+ end
+ format.html { render action: 'permission_denied', status: :forbidden }
+ format.json { render json: "Permission denied", status: :forbidden }
+ end
#when "close"
# TODO
else
@@ -117,6 +123,6 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
- params.require(:tournament).permit(:game, :game_id, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :status)
+ params.require(:tournament).permit(:game, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams)
end
end