refactored approval system - now with comments

This commit is contained in:
Mark Moser
2017-03-02 10:32:02 -06:00
parent 854b60bc8c
commit c38e0c9bf8
10 changed files with 84 additions and 106 deletions

View File

@ -15,7 +15,7 @@ class ReviewerVote < ApplicationRecord
enum veto: {
approved: 1,
rejected: 2
declined: 2
}
private

View File

@ -38,20 +38,16 @@ class User < ApplicationRecord
vote.save
end
def approve_candidate candidate
def review_candidate candidate, parms_hash
candidate = Candidate.find(candidate.to_i)
vote = votes.find_by(candidate_id: candidate.to_i)
vote.veto = :approved
candidate.update_attribute(:review_status, :approved) if vote.save
end
def decline_candidate candidate
candidate = Candidate.find(candidate.to_i)
vote = votes.find_by(candidate_id: candidate.to_i)
vote.veto = :rejected
candidate.update_attribute(:review_status, :declined) if vote.save
vote.veto = parms_hash[:review_status]
if vote.save
# skipping validations on candidate because that's not the managers responsibility
candidate.review_comments = parms_hash[:review_comments]
candidate.update_attribute(:review_status, parms_hash[:review_status])
end
end
def my_vote candidate