diff options
author | Luke Shumaker <shumakl@purdue.edu> | 2014-04-04 23:51:32 -0400 |
---|---|---|
committer | Luke Shumaker <shumakl@purdue.edu> | 2014-04-04 23:51:32 -0400 |
commit | 18d76defd43cb747824a355b2d320c5cf2c55d6a (patch) | |
tree | 8d664a67b9bbba1e9a991bea07e6d07d358260f0 /app | |
parent | fca133856e323d01aa88e0e60acba762378dd9e3 (diff) |
fix issues in tournaments controller
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/tournaments_controller.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 010f279..a9e91b0 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -70,23 +70,25 @@ class TournamentsController < ApplicationController end end when "join" - check_permission(:join) + # permission checking for join is done in the Tournament model respond_to do |format| if @tournament.join(current_user) format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } format.json { head :no_content } + else + format.html { redirect_to @tournament, notice: "You can't join this tournament." } + format.json { render json: "Permission denied", status: :forbidden } end - format.html { render action: 'permission_denied', status: :forbidden } - format.json { render json: "Permission denied", status: :forbidden } end when "leave" respond_to do |format| if @tournament.leave(current_user) format.html { redirect_to tournaments_url, notice: 'You have left the tournament.' } format.json { head :no_content } + else + format.html { redirect_to @tournament, notice: 'You were\'t a part of this tournament.' } + format.json { render json: "Permission denied", status: :forbidden } 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 "start" check_permission(:edit, @tournament) @@ -96,9 +98,10 @@ class TournamentsController < ApplicationController if @tournament.setup format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } format.json { head :no_content } + else + format.html { render action: 'permission_denied', status: :forbidden } + format.json { render json: "Permission denied", status: :forbidden } end - format.html { render action: 'permission_denied', status: :forbidden } - format.json { render json: "Permission denied", status: :forbidden } end else respond_to do |format| |