mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-08 07:22:38 +00:00
First crack at setting an owner for the tournament
This commit is contained in:
@@ -19,13 +19,13 @@ class MatchesController < ApplicationController
|
||||
|
||||
# GET /matches/1/edit
|
||||
def edit
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
if params[:match]
|
||||
@match = Match.find (params[:match])
|
||||
end
|
||||
if current_user == @match.tournament.user
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
if @match
|
||||
@w1 = Wrestler.find(@match.w1)
|
||||
@w2 = Wrestler.find(@match.w2)
|
||||
@@ -55,7 +55,7 @@ class MatchesController < ApplicationController
|
||||
# PATCH/PUT /matches/1
|
||||
# PATCH/PUT /matches/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
if current_user == @match.tournament.user
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
@@ -18,6 +18,9 @@ class MatsController < ApplicationController
|
||||
if params[:tournament]
|
||||
@tournament_field = params[:tournament]
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,12 +32,11 @@ class MatsController < ApplicationController
|
||||
# POST /mats
|
||||
# POST /mats.json
|
||||
def create
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@mat = Mat.new(mat_params)
|
||||
@tournament = Tournament.find(mat_params[:tournament_id])
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
respond_to do |format|
|
||||
if @mat.save
|
||||
format.html { redirect_to @tournament, notice: 'Mat was successfully created.' }
|
||||
@@ -49,11 +51,10 @@ class MatsController < ApplicationController
|
||||
# PATCH/PUT /mats/1
|
||||
# PATCH/PUT /mats/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@mat.tournament_id)
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
respond_to do |format|
|
||||
if @mat.update(mat_params)
|
||||
format.html { redirect_to @tournament, notice: 'Mat was successfully updated.' }
|
||||
@@ -68,11 +69,10 @@ class MatsController < ApplicationController
|
||||
# DELETE /mats/1
|
||||
# DELETE /mats/1.json
|
||||
def destroy
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@mat.tournament_id)
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
@mat.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to @tournament }
|
||||
|
||||
@@ -32,12 +32,11 @@ class SchoolsController < ApplicationController
|
||||
# POST /schools
|
||||
# POST /schools.json
|
||||
def create
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@school = School.new(school_params)
|
||||
@tournament = Tournament.find(school_params[:tournament_id])
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
respond_to do |format|
|
||||
if @school.save
|
||||
format.html { redirect_to @tournament, notice: 'School was successfully created.' }
|
||||
@@ -52,11 +51,10 @@ class SchoolsController < ApplicationController
|
||||
# PATCH/PUT /schools/1
|
||||
# PATCH/PUT /schools/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@school.tournament_id)
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
respond_to do |format|
|
||||
if @school.update(school_params)
|
||||
format.html { redirect_to @tournament, notice: 'School was successfully updated.' }
|
||||
@@ -71,11 +69,10 @@ class SchoolsController < ApplicationController
|
||||
# DELETE /schools/1
|
||||
# DELETE /schools/1.json
|
||||
def destroy
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@school.tournament_id)
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
@school.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to @tournament }
|
||||
|
||||
@@ -68,12 +68,11 @@ class StaticPagesController < ApplicationController
|
||||
end
|
||||
|
||||
def createCustomWeights
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
@custom = params[:customValue].to_s
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
@custom = params[:customValue].to_s
|
||||
@tournament.createCustomWeights(@custom)
|
||||
|
||||
redirect_to "/tournaments/#{@tournament.id}"
|
||||
@@ -92,6 +91,9 @@ class StaticPagesController < ApplicationController
|
||||
elsif user_signed_in?
|
||||
if params[:tournament]
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
if @tournament
|
||||
@tournament.generateMatchups
|
||||
@@ -108,6 +110,9 @@ class StaticPagesController < ApplicationController
|
||||
end
|
||||
if params[:tournament]
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament_id = @tournament.id
|
||||
@tournament_name = @tournament.name
|
||||
end
|
||||
|
||||
@@ -46,10 +46,9 @@ class TournamentsController < ApplicationController
|
||||
# PATCH/PUT /tournaments/1
|
||||
# PATCH/PUT /tournaments/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
respond_to do |format|
|
||||
if @tournament.update(tournament_params)
|
||||
format.html { redirect_to @tournament, notice: 'Tournament was successfully updated.' }
|
||||
@@ -64,10 +63,9 @@ class TournamentsController < ApplicationController
|
||||
# DELETE /tournaments/1
|
||||
# DELETE /tournaments/1.json
|
||||
def destroy
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to tournaments_url }
|
||||
|
||||
@@ -37,13 +37,11 @@ class WeightsController < ApplicationController
|
||||
# POST /weights
|
||||
# POST /weights.json
|
||||
def create
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@weight = Weight.new(weight_params)
|
||||
@tournament = Tournament.find(weight_params[:tournament_id])
|
||||
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
respond_to do |format|
|
||||
if @weight.save
|
||||
format.html { redirect_to @tournament, notice: 'Weight was successfully created.' }
|
||||
@@ -58,11 +56,10 @@ class WeightsController < ApplicationController
|
||||
# PATCH/PUT /weights/1
|
||||
# PATCH/PUT /weights/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@weight.tournament_id)
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
respond_to do |format|
|
||||
if @weight.update(weight_params)
|
||||
format.html { redirect_to @tournament, notice: 'Weight was successfully updated.' }
|
||||
@@ -77,11 +74,10 @@ class WeightsController < ApplicationController
|
||||
# DELETE /weights/1
|
||||
# DELETE /weights/1.json
|
||||
def destroy
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@weight.tournament_id)
|
||||
if current_user != @tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
@weight.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to @tournament }
|
||||
|
||||
@@ -43,11 +43,10 @@ class WrestlersController < ApplicationController
|
||||
# POST /wrestlers
|
||||
# POST /wrestlers.json
|
||||
def create
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@wrestler = Wrestler.new(wrestler_params)
|
||||
if current_user != @wrestler.tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
@school = School.find(wrestler_params[:school_id])
|
||||
respond_to do |format|
|
||||
if @wrestler.save
|
||||
@@ -63,10 +62,9 @@ class WrestlersController < ApplicationController
|
||||
# PATCH/PUT /wrestlers/1
|
||||
# PATCH/PUT /wrestlers/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
if current_user != @wrestler.tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
@school = School.find(@wrestler.school_id)
|
||||
respond_to do |format|
|
||||
if @wrestler.update(wrestler_params)
|
||||
@@ -82,10 +80,9 @@ class WrestlersController < ApplicationController
|
||||
# DELETE /wrestlers/1
|
||||
# DELETE /wrestlers/1.json
|
||||
def destroy
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
if current_user != @wrestler.tournament.user
|
||||
redirect_to root_path
|
||||
end
|
||||
@school = School.find(@wrestler.school_id)
|
||||
@wrestler.destroy
|
||||
respond_to do |format|
|
||||
|
||||
Reference in New Issue
Block a user