summaryrefslogtreecommitdiff
path: root/app/controllers/tournaments_controller.rb
diff options
context:
space:
mode:
authorguntasgrewal <guntasgrewal@gmail.com>2014-04-06 20:09:54 -0400
committerguntasgrewal <guntasgrewal@gmail.com>2014-04-06 20:09:54 -0400
commitf3c395c56a644d976aa9a5608300557600bc683e (patch)
tree83cb961a721fa8c50903c70bb08ae14dd15ca58c /app/controllers/tournaments_controller.rb
parent7575d8cc70a28b323db0486ed06ab8af33b1f21a (diff)
parentf85943114dba527a1f87abb03229553472f57c0c (diff)
solved merge conflicts
Diffstat (limited to 'app/controllers/tournaments_controller.rb')
-rw-r--r--app/controllers/tournaments_controller.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 010f279..2fc82ed 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 { redirect_to @tournament, notice: "You don't have permission to start 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
else
respond_to do |format|