summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/tournaments_controller.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 4f79d44..8ed8cc9 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -1,5 +1,5 @@
class TournamentsController < ApplicationController
- before_action :set_tournament, only: [:show, :edit, :update, :destroy]
+ before_action :set_tournament, only: [:show, :edit, :update, :destroy, :join]
before_action :check_perms, only: [:new, :create, :edit, :update, :destroy]
# GET /tournaments
@@ -63,13 +63,26 @@ class TournamentsController < ApplicationController
end
end
+ # POST /tournaments/1/join
+ # POST /tournaments/1/join.json
+ def join
+ 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 }
+ end
+ format.html { render action: 'permission_denied', status: :forbidden }
+ format.json { render json: "Permission denied", status: :forbidden }
+ end
+ end
+
private
# Use callbacks to share common setup or constraints between actions.
def set_tournament
@tournament = Tournament.find(params[:id])
end
- def check_perms
+ def check_perms
unless (signed_in? and current_user.in_group?(:host))
respond_to do |format|
format.html { render action: 'permission_denied', status: :forbidden }