skill-assessment-app/app/controllers/admin/vote_controller.rb
2016-11-30 19:00:42 -06:00

35 lines
1.1 KiB
Ruby

# frozen_string_literal: true
module Admin
class VoteController < AdminController
def up
@candidate = Candidate.find_by(test_hash: params[:test_hash])
authorize ReviewerVote.find_by(user_id: current_user.id, candidate_id: @candidate.id)
current_user.cast_yea_on(@candidate)
end
def down
@candidate = Candidate.find_by(test_hash: params[:test_hash])
authorize ReviewerVote.find_by(user_id: current_user.id, candidate_id: @candidate.id)
current_user.cast_nay_on(@candidate)
end
def approve
@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
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)
if current_user.decline_candidate(@candidate)
RecruiterMailer.interview_declined(@candidate).deliver_later
end
end
end
end