mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-02 04:35:26 +00:00
School delegates permissions are working
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
class SchoolsController < ApplicationController
|
||||
before_action :set_school, only: [:show, :edit, :update, :destroy]
|
||||
before_filter :check_access, only: [:new,:create,:update,:destroy,:edit]
|
||||
before_filter :check_access_director, only: [:new,:create,:destroy]
|
||||
before_filter :check_access_delegate, only: [:update,:edit]
|
||||
|
||||
|
||||
# GET /schools/1
|
||||
@@ -76,15 +77,21 @@ class SchoolsController < ApplicationController
|
||||
params.require(:school).permit(:name, :score, :tournament_id)
|
||||
end
|
||||
|
||||
def check_access
|
||||
def check_access_director
|
||||
if params[:tournament]
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
elsif params[:school]
|
||||
@tournament = Tournament.find(params[:school]["tournament_id"])
|
||||
elsif @school
|
||||
@tournament = @school.tournament
|
||||
elsif school_params
|
||||
@tournament = Tournament.find(school_params[:tournament_id])
|
||||
end
|
||||
authorize! :manage, @tournament
|
||||
end
|
||||
|
||||
def check_access_delegate
|
||||
authorize! :manage, @school
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -92,13 +92,16 @@ class WrestlersController < ApplicationController
|
||||
def check_access
|
||||
if params[:school]
|
||||
@school = School.find(params[:school])
|
||||
@tournament = Tournament.find(@school.tournament.id)
|
||||
#@tournament = Tournament.find(@school.tournament.id)
|
||||
elsif params[:wrestler]
|
||||
@school = School.find(params[:wrestler]["school_id"])
|
||||
@tournament = Tournament.find(@school.tournament.id)
|
||||
#@tournament = Tournament.find(@school.tournament.id)
|
||||
elsif @wrestler
|
||||
@tournament = @wrestler.tournament
|
||||
@school = @wrestler.school
|
||||
#@tournament = @wrestler.tournament
|
||||
elsif wrestler_params
|
||||
@school = School.find(wrestler_params[:school_id])
|
||||
end
|
||||
authorize! :manage, @tournament
|
||||
authorize! :manage, @school
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user