2017-02-13 15:04:47 -06:00
|
|
|
# frozen_string_literal: true
|
|
|
|
class QuizCommentPolicy < ApplicationPolicy
|
|
|
|
# Quiz Comment Policy
|
|
|
|
#
|
2017-02-14 10:17:42 -06:00
|
|
|
# Anyone who can vote on results, can comment
|
|
|
|
# Only comment owner can edit her comment
|
2017-02-13 15:04:47 -06:00
|
|
|
|
2017-02-14 10:17:42 -06:00
|
|
|
def new?
|
2017-02-13 15:04:47 -06:00
|
|
|
user.acts_as_reviewer?
|
|
|
|
end
|
|
|
|
|
2017-02-14 10:17:42 -06:00
|
|
|
def create?
|
2017-02-27 13:41:46 -06:00
|
|
|
return true if user.acts_as_admin?
|
|
|
|
|
|
|
|
user.acts_as_reviewer? &&
|
|
|
|
record.candidate.reviewers.where(id: user.id).count.positive?
|
2017-02-13 15:04:47 -06:00
|
|
|
end
|
|
|
|
|
2017-02-14 10:17:42 -06:00
|
|
|
def update?
|
|
|
|
user.acts_as_reviewer? && user.id == record.user_id
|
2017-02-13 15:04:47 -06:00
|
|
|
end
|
|
|
|
end
|