2016-11-19 16:34:48 -06:00
|
|
|
# frozen_string_literal: true
|
|
|
|
class ReviewerVotePolicy < ApplicationPolicy
|
|
|
|
# Voting Policy
|
|
|
|
#
|
|
|
|
# Only Reviewers, Managers, and Admins, can cast a vote on a quiz result
|
|
|
|
#
|
|
|
|
# Reviewers can vote any quiz they are linked to
|
|
|
|
# Only Managers, and Admins, can veto a quiz result
|
|
|
|
|
|
|
|
def up?
|
2016-11-20 09:51:46 -06:00
|
|
|
# return true if user.reviewees.include? record.candidate
|
2016-11-19 16:34:48 -06:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def down?
|
|
|
|
# return true if user.acts_as_manager?
|
|
|
|
# user.quizzes.include? record
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def approve?
|
|
|
|
user.acts_as_manager?
|
|
|
|
end
|
|
|
|
|
|
|
|
def decline?
|
|
|
|
user.acts_as_manager?
|
|
|
|
end
|
|
|
|
|
|
|
|
class Scope < Scope
|
|
|
|
def resolve
|
|
|
|
return ReviewerVote.none if user.recruiter?
|
|
|
|
|
|
|
|
if user.reviewer?
|
|
|
|
scope.where(user_id: user.id)
|
|
|
|
else
|
|
|
|
scope
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|