summaryrefslogtreecommitdiff
path: root/app/controllers/tournaments_controller.rb
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-03-06 22:17:36 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-03-06 22:17:36 -0500
commit5f2247dd1e701a91fb0359bf7265bdadd5486a60 (patch)
tree8966f53e304731faf26b19230439f831b215d3f1 /app/controllers/tournaments_controller.rb
parent4a91128f6fe20d95b6692abaa5e6c4dc92418b46 (diff)
parent2bfc17c39f9b8b5ea71d36d2d5f041295f24192f (diff)
Merge branch 'master' of github.com:LukeShu/leaguer
Conflicts: config/routes.rb
Diffstat (limited to 'app/controllers/tournaments_controller.rb')
-rw-r--r--app/controllers/tournaments_controller.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 27765df..74a1f56 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -11,12 +11,16 @@ class TournamentsController < ApplicationController
# GET /tournaments/1
# GET /tournaments/1.json
def show
+ unless @tournament.status
+ redirect_to tournament_matches_page(@tournament)
+ end
end
# GET /tournaments/new
def new
@games = Game.all
@tournament = Tournament.new(game: Game.find_by_id(params[:game]))
+ @tournament.status = 1
end
# GET /tournaments/1/edit
@@ -42,8 +46,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|
@@ -66,8 +69,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