diff options
author | Luke Shumaker <shumakl@purdue.edu> | 2014-04-04 20:44:43 -0400 |
---|---|---|
committer | Luke Shumaker <shumakl@purdue.edu> | 2014-04-04 20:44:43 -0400 |
commit | 38d6960be1efdb6345445ab293a8cd605193785f (patch) | |
tree | df37e79b5744b570aded5aa4d7fe38cd772a49fe /app/controllers/tournaments_controller.rb | |
parent | bcfa571b0328a4b3e94479a31c027621ceb86ad5 (diff) | |
parent | d14dcf9af11a0f2eab2609efb7d9e59a9cc18bb0 (diff) |
Merge branch 'master' into luke
Conflicts:
app/controllers/application_controller.rb
app/controllers/tournaments_controller.rb
Diffstat (limited to 'app/controllers/tournaments_controller.rb')
-rw-r--r-- | app/controllers/tournaments_controller.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 2d63068..d1a926b 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -69,12 +69,11 @@ class TournamentsController < ApplicationController format.json { render json: @tournament.errors, status: :unprocessable_entity } end end - when "join" check_permission(:join) respond_to do |format| if @tournament.join(current_user) - format.html { render action: 'show', notice: 'You have joined this tournament.' } + format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } format.json { head :no_content } end format.html { render action: 'permission_denied', status: :forbidden } @@ -83,17 +82,19 @@ class TournamentsController < ApplicationController when "leave" respond_to do |format| if @tournament.leave(current_user) - format.html {redirect_to tournaments_url, notice: 'You have left the tournament.' } + format.html { redirect_to tournaments_url, notice: 'You have left the tournament.' } format.json { head :no_content } end format.html {redirect_to @tournament, notice: 'You were\'t a part of this tournament.' } format.json { render json: "Permission denied", status: :forbidden } end - when "open" + when "start" check_permission(:edit, @tournament) + @tournament.status = 1 + @tournament.save respond_to do |format| if @tournament.setup - format.html { render action: 'show', notice: 'You have joined this tournament.' } + format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } format.json { head :no_content } end format.html { render action: 'permission_denied', status: :forbidden } @@ -101,7 +102,7 @@ class TournamentsController < ApplicationController end else respond_to do |format| - format.html { render action: 'show', notice: "Invalid action", status: :unprocessable_entity } + format.html { redirect_to @tournament, notice: "Invalid action", status: :unprocessable_entity } format.json { render json: @tournament.errors, status: :unprocessable_entity } end end |