refactored approval system - now with comments
This commit is contained in:
@ -15,7 +15,7 @@ class ReviewerVote < ApplicationRecord
|
||||
|
||||
enum veto: {
|
||||
approved: 1,
|
||||
rejected: 2
|
||||
declined: 2
|
||||
}
|
||||
|
||||
private
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user