blob: bbc2b48b8567e24813d0305c871df7a22d96b545 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# frozen_string_literal: true
class NotePolicy < BasePolicy
delegate { @subject.project }
delegate { @subject.noteable if DeclarativePolicy.has_policy?(@subject.noteable) }
condition(:is_author) { @user && @subject.author == @user }
condition(:is_noteable_author) { @user && @subject.noteable.author_id == @user.id }
condition(:editable, scope: :subject) { @subject.editable? }
rule { ~editable }.prevent :admin_note
rule { is_author }.policy do
enable :read_note
enable :admin_note
enable :resolve_note
end
rule { is_noteable_author }.policy do
enable :resolve_note
end
end
|