2016-11-19 16:34:48 -06:00
|
|
|
# frozen_string_literal: true
|
|
|
|
module Admin
|
|
|
|
class VoteController < AdminController
|
|
|
|
def up
|
|
|
|
@candidate = Candidate.find_by(test_hash: params[:test_hash])
|
2016-11-20 13:07:53 -06:00
|
|
|
authorize ReviewerVote.find_by(user_id: current_user.id, candidate_id: @candidate.id)
|
2016-11-19 16:34:48 -06:00
|
|
|
current_user.cast_yea_on(@candidate)
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
@candidate = Candidate.find_by(test_hash: params[:test_hash])
|
2016-11-20 13:07:53 -06:00
|
|
|
authorize ReviewerVote.find_by(user_id: current_user.id, candidate_id: @candidate.id)
|
2016-11-19 16:34:48 -06:00
|
|
|
current_user.cast_nay_on(@candidate)
|
|
|
|
end
|
|
|
|
|
2017-03-02 10:32:02 -06:00
|
|
|
def interview_request
|
2016-11-19 16:34:48 -06:00
|
|
|
@candidate = Candidate.find_by(test_hash: params[:test_hash])
|
2016-11-20 13:07:53 -06:00
|
|
|
authorize ReviewerVote.find_by(user_id: current_user.id, candidate_id: @candidate.id)
|
2016-11-19 16:34:48 -06:00
|
|
|
|
2017-03-02 10:32:02 -06:00
|
|
|
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]}" }
|
2016-11-19 16:34:48 -06:00
|
|
|
end
|
|
|
|
|
2017-03-02 10:32:02 -06:00
|
|
|
private
|
2016-11-19 16:34:48 -06:00
|
|
|
|
2017-03-02 10:32:02 -06:00
|
|
|
def interview_params
|
|
|
|
params.permit(:review_status, :review_comments)
|
2016-11-30 18:55:27 -06:00
|
|
|
end
|
2016-11-19 16:34:48 -06:00
|
|
|
end
|
|
|
|
end
|