f694f94c49
This class can be used to reduce a list of issues down to a subset based on user permissions. This class operates in such a way that it can reduce issues using as few queries as possible, if any at all.
23 lines
390 B
Ruby
23 lines
390 B
Ruby
class IssuePolicy < IssuablePolicy
|
|
def issue
|
|
@subject
|
|
end
|
|
|
|
def rules
|
|
super
|
|
|
|
if @subject.confidential? && !can_read_confidential?
|
|
cannot! :read_issue
|
|
cannot! :update_issue
|
|
cannot! :admin_issue
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def can_read_confidential?
|
|
return false unless @user
|
|
|
|
IssueCollection.new([@subject]).updatable_by_user(@user).any?
|
|
end
|
|
end
|