admin global nav

This commit is contained in:
Mark Moser
2016-09-22 16:29:19 -05:00
parent aeef75bf8b
commit 5398a8ea8b
14 changed files with 64 additions and 67 deletions

View File

@ -4,7 +4,7 @@ module Admin
before_action :collect_quizzes, except: [:login, :auth]
def index
@candidates = policy_scope current_recruiter.candidates
@candidates = policy_scope Candidate.order(:name)
end
def new
@ -15,7 +15,7 @@ module Admin
def create
authorize Candidate
@candidate = Candidate.create(candidate_params.merge(recruiter_id: current_recruiter.id))
@candidate = Candidate.create(candidate_params.merge(recruiter_id: current_user.id))
if @candidate.persisted?
send_notifications @candidate

View File

@ -3,8 +3,25 @@ module Admin
class DashboardController < AdminController
def show
authorize :dashboard
@quizzes = policy_scope Quiz.includes(:questions).all
@users = policy_scope User.order(:role, :name)
send "redirect_for_#{current_user.role}"
end
private
def redirect_for_admin
redirect_to admin_users_url
end
def redirect_for_manager
redirect_to admin_quizzes_url
end
def redirect_for_reviewer
redirect_to admin_results_url
end
def redirect_for_recruiter
redirect_to admin_candidates_url
end
end
end

View File

@ -4,16 +4,6 @@ class ApplicationController < ActionController::Base
add_flash_types :warning, :success
def current_recruiter
user_parms = { id: session[:user], role: %w(admin recruiter) }
@current_recruiter ||= User.find_by(user_parms) if session[:user]
end
def current_reviewer
user_parms = { id: session[:user], role: %w(admin reviewer) }
@current_reviewer ||= User.find_by(user_parms) if session[:user]
end
def current_candidate
@current_candidate ||= Candidate.find_by(test_hash: session[:test_id]) if session[:test_id]
end
@ -29,14 +19,6 @@ class ApplicationController < ActionController::Base
params.require(:auth).permit(:email, :password)
end
def authorize_recruiter
redirect_to recruiter_login_path unless current_recruiter
end
def authorize_reviewer
redirect_to review_login_path unless current_reviewer
end
def authorize_candidate
redirect_to login_path unless current_candidate
end