normalise some json responses
This commit is contained in:
parent
fa27aac083
commit
bc31f6cf17
@ -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
|
||||
|
@ -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
|
||||
|
1
app/views/admin/candidate/resend_welcome.json.erb
Normal file
1
app/views/admin/candidate/resend_welcome.json.erb
Normal file
@ -0,0 +1 @@
|
||||
{ "message" : "Email queued!" }
|
5
app/views/admin/vote/approve.json.erb
Normal file
5
app/views/admin/vote/approve.json.erb
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"message" : "Interview requested!",
|
||||
"requestCopy" : "Requested",
|
||||
"declineCopy" : "Decline Interview"
|
||||
}
|
5
app/views/admin/vote/decline.json.erb
Normal file
5
app/views/admin/vote/decline.json.erb
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"message" : "Interview declined.",
|
||||
"requestCopy" : "Request Interview",
|
||||
"declineCopy" : "Declined"
|
||||
}
|
6
app/views/admin/vote/down.json.erb
Normal file
6
app/views/admin/vote/down.json.erb
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"message" : "Vote Counted",
|
||||
"upCount" : <%= @candidate.votes.yea.count %>,
|
||||
"downCount" : <%= @candidate.votes.nay.count %>,
|
||||
"myVote" : "nay"
|
||||
}
|
6
app/views/admin/vote/up.json.erb
Normal file
6
app/views/admin/vote/up.json.erb
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"message" : "Vote Counted",
|
||||
"upCount" : <%= @candidate.votes.yea.count %>,
|
||||
"downCount" : <%= @candidate.votes.nay.count %>,
|
||||
"myVote" : "yea"
|
||||
}
|
@ -45,15 +45,15 @@ Rails.application.routes.draw do
|
||||
post "/admin/candidate/new", to: "admin/candidate#create", as: :admin_create_candidate
|
||||
get "/admin/candidate/:id", to: "admin/candidate#edit", as: :admin_edit_candidate
|
||||
post "/admin/candidate/:id", to: "admin/candidate#update", as: :admin_update_candidate
|
||||
get "/admin/candidate/:id/resend", to: "admin/candidate#resend_welcome", as: :admin_resend_welcome
|
||||
get "/admin/candidate/:id/resend", to: "admin/candidate#resend_welcome", as: :admin_resend_welcome, defaults: { format: 'json' }
|
||||
|
||||
get "/admin/results", to: "admin/result#index", as: :admin_results
|
||||
get "/admin/result/:test_hash", to: "admin/result#view", as: :admin_result
|
||||
|
||||
get "admin/vote/:test_hash/up", to: "admin/vote#up", as: :admin_up_vote
|
||||
get "admin/vote/:test_hash/down", to: "admin/vote#down", as: :admin_down_vote
|
||||
get "admin/vote/:test_hash/approve", to: "admin/vote#approve", as: :admin_approve_vote
|
||||
get "admin/vote/:test_hash/decline", to: "admin/vote#decline", as: :admin_decline_vote
|
||||
get "admin/vote/:test_hash/up", to: "admin/vote#up", as: :admin_up_vote, defaults: { format: 'json' }
|
||||
get "admin/vote/:test_hash/down", to: "admin/vote#down", as: :admin_down_vote, defaults: { format: 'json' }
|
||||
get "admin/vote/:test_hash/approve", to: "admin/vote#approve", as: :admin_approve_vote, defaults: { format: 'json' }
|
||||
get "admin/vote/:test_hash/decline", to: "admin/vote#decline", as: :admin_decline_vote, defaults: { format: 'json' }
|
||||
|
||||
get "/admin", to: "admin/dashboard#show", as: :admin
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user