vote/veto processing
This commit is contained in:
48
app/controllers/admin/vote_controller.rb
Normal file
48
app/controllers/admin/vote_controller.rb
Normal file
@ -0,0 +1,48 @@
|
||||
# frozen_string_literal: true
|
||||
module Admin
|
||||
class VoteController < AdminController
|
||||
def up
|
||||
authorize ReviewerVote
|
||||
@candidate = Candidate.find_by(test_hash: params[:test_hash])
|
||||
current_user.cast_yea_on(@candidate)
|
||||
|
||||
results = {
|
||||
message: "Vote tallied!",
|
||||
upCount: @candidate.votes.yea.count,
|
||||
downCount: @candidate.votes.nay.count
|
||||
}
|
||||
render json: results.to_json
|
||||
end
|
||||
|
||||
def down
|
||||
authorize ReviewerVote
|
||||
@candidate = Candidate.find_by(test_hash: params[:test_hash])
|
||||
current_user.cast_nay_on(@candidate)
|
||||
|
||||
results = {
|
||||
message: "Vote tallied!",
|
||||
upCount: @candidate.votes.yea.count,
|
||||
downCount: @candidate.votes.nay.count
|
||||
}
|
||||
render json: results.to_json
|
||||
end
|
||||
|
||||
def approve
|
||||
authorize ReviewerVote
|
||||
@candidate = Candidate.find_by(test_hash: params[:test_hash])
|
||||
current_user.approve_candidate(@candidate)
|
||||
|
||||
results = { message: "Interview requested!" }
|
||||
render json: results.to_json
|
||||
end
|
||||
|
||||
def decline
|
||||
authorize ReviewerVote
|
||||
@candidate = Candidate.find_by(test_hash: params[:test_hash])
|
||||
current_user.decline_candidate(@candidate)
|
||||
|
||||
results = { message: "Interview declined." }
|
||||
render json: results.to_json
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user