refactored approval system - now with comments

This commit is contained in:
Mark Moser
2017-03-02 10:32:02 -06:00
parent 854b60bc8c
commit c38e0c9bf8
10 changed files with 84 additions and 106 deletions

View File

@ -13,22 +13,20 @@ module Admin
current_user.cast_nay_on(@candidate)
end
def approve
def interview_request
@candidate = Candidate.find_by(test_hash: params[:test_hash])
authorize ReviewerVote.find_by(user_id: current_user.id, candidate_id: @candidate.id)
if current_user.approve_candidate(@candidate)
RecruiterMailer.interview_requested(@candidate).deliver_later
end
current_user.review_candidate(@candidate, interview_params)
RecruiterMailer.candidate_reviewed(@candidate).deliver_later
redirect_to admin_result_path(@candidate.test_hash),
flash: { notice: "Quiz #{interview_params[:review_status]}" }
end
def decline
@candidate = Candidate.find_by(test_hash: params[:test_hash])
authorize ReviewerVote.find_by(user_id: current_user.id, candidate_id: @candidate.id)
private
if current_user.decline_candidate(@candidate)
RecruiterMailer.interview_declined(@candidate).deliver_later
def interview_params
params.permit(:review_status, :review_comments)
end
end
end
end