gitlab-org--gitlab-foss/app/policies/note_policy.rb

22 lines
565 B
Ruby
Raw Normal View History

2016-08-16 20:08:14 +00:00
class NotePolicy < BasePolicy
delegate { @subject.project }
delegate { @subject.noteable if @subject.noteable.lockable? }
2016-08-16 20:08:14 +00:00
condition(:is_author) { @user && @subject.author == @user }
condition(:is_noteable_author) { @user && @subject.noteable.author_id == @user.id }
2016-08-16 20:08:14 +00:00
condition(:editable, scope: :subject) { @subject.editable? }
2016-08-16 20:08:14 +00:00
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
2016-08-16 20:08:14 +00:00
end
end