normalise some json responses

This commit is contained in:
Mark Moser
2016-11-30 19:00:42 -06:00
parent fa27aac083
commit bc31f6cf17
8 changed files with 28 additions and 34 deletions

View File

@ -49,7 +49,6 @@ module Admin
authorize Candidate
candidate = Candidate.find_by(id: params[:id])
CandidateMailer.welcome(candidate).deliver_later
render json: { message: "Email queued!" }.to_json
end
private

View File

@ -5,28 +5,12 @@ module Admin
@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)
results = {
message: "Vote Counted",
upCount: @candidate.votes.yea.count,
downCount: @candidate.votes.nay.count,
myVote: "yea"
}
render json: results.to_json
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)
results = {
message: "Vote Counted",
upCount: @candidate.votes.yea.count,
downCount: @candidate.votes.nay.count,
myVote: "nay"
}
render json: results.to_json
end
def approve
@ -35,12 +19,6 @@ module Admin
if current_user.approve_candidate(@candidate)
RecruiterMailer.interview_requested(@candidate).deliver_later
results = {
message: "Interview requested!",
requestCopy: "Requested",
declineCopy: "Decline Interview"
}
render json: results.to_json
end
end
@ -50,12 +28,6 @@ module Admin
if current_user.decline_candidate(@candidate)
RecruiterMailer.interview_declined(@candidate).deliver_later
results = {
message: "Interview declined.",
requestCopy: "Request Interview",
declineCopy: "Declined"
}
render json: results.to_json
end
end
end

View File

@ -0,0 +1 @@
{ "message" : "Email queued!" }

View File

@ -0,0 +1,5 @@
{
"message" : "Interview requested!",
"requestCopy" : "Requested",
"declineCopy" : "Decline Interview"
}

View File

@ -0,0 +1,5 @@
{
"message" : "Interview declined.",
"requestCopy" : "Request Interview",
"declineCopy" : "Declined"
}

View File

@ -0,0 +1,6 @@
{
"message" : "Vote Counted",
"upCount" : <%= @candidate.votes.yea.count %>,
"downCount" : <%= @candidate.votes.nay.count %>,
"myVote" : "nay"
}

View File

@ -0,0 +1,6 @@
{
"message" : "Vote Counted",
"upCount" : <%= @candidate.votes.yea.count %>,
"downCount" : <%= @candidate.votes.nay.count %>,
"myVote" : "yea"
}