diff --git a/app/controllers/admin/candidate_controller.rb b/app/controllers/admin/candidate_controller.rb index 5a95b68..843f762 100644 --- a/app/controllers/admin/candidate_controller.rb +++ b/app/controllers/admin/candidate_controller.rb @@ -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 diff --git a/app/controllers/admin/vote_controller.rb b/app/controllers/admin/vote_controller.rb index 45cbd4e..acf2008 100644 --- a/app/controllers/admin/vote_controller.rb +++ b/app/controllers/admin/vote_controller.rb @@ -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 diff --git a/app/views/admin/candidate/resend_welcome.json.erb b/app/views/admin/candidate/resend_welcome.json.erb new file mode 100644 index 0000000..fbba8af --- /dev/null +++ b/app/views/admin/candidate/resend_welcome.json.erb @@ -0,0 +1 @@ +{ "message" : "Email queued!" } diff --git a/app/views/admin/vote/approve.json.erb b/app/views/admin/vote/approve.json.erb new file mode 100644 index 0000000..1aa0072 --- /dev/null +++ b/app/views/admin/vote/approve.json.erb @@ -0,0 +1,5 @@ +{ + "message" : "Interview requested!", + "requestCopy" : "Requested", + "declineCopy" : "Decline Interview" +} diff --git a/app/views/admin/vote/decline.json.erb b/app/views/admin/vote/decline.json.erb new file mode 100644 index 0000000..6d98faf --- /dev/null +++ b/app/views/admin/vote/decline.json.erb @@ -0,0 +1,5 @@ +{ + "message" : "Interview declined.", + "requestCopy" : "Request Interview", + "declineCopy" : "Declined" +} diff --git a/app/views/admin/vote/down.json.erb b/app/views/admin/vote/down.json.erb new file mode 100644 index 0000000..fe06c20 --- /dev/null +++ b/app/views/admin/vote/down.json.erb @@ -0,0 +1,6 @@ +{ + "message" : "Vote Counted", + "upCount" : <%= @candidate.votes.yea.count %>, + "downCount" : <%= @candidate.votes.nay.count %>, + "myVote" : "nay" +} diff --git a/app/views/admin/vote/up.json.erb b/app/views/admin/vote/up.json.erb new file mode 100644 index 0000000..605d7e1 --- /dev/null +++ b/app/views/admin/vote/up.json.erb @@ -0,0 +1,6 @@ +{ + "message" : "Vote Counted", + "upCount" : <%= @candidate.votes.yea.count %>, + "downCount" : <%= @candidate.votes.nay.count %>, + "myVote" : "yea" +} diff --git a/config/routes.rb b/config/routes.rb index 691f4c5..0fbe80c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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