debian-mirror-gitlab/app/policies/note_policy.rb

27 lines
799 B
Ruby
Raw Normal View History

2016-09-29 09:46:39 +05:30
class NotePolicy < BasePolicy
2017-09-10 17:25:29 +05:30
delegate { @subject.project }
2018-03-17 18:26:18 +05:30
delegate { @subject.noteable if @subject.noteable.lockable? }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
condition(:is_author) { @user && @subject.author == @user }
condition(:for_merge_request, scope: :subject) { @subject.for_merge_request? }
condition(:is_noteable_author) { @user && @subject.noteable.author_id == @user.id }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
condition(:editable, scope: :subject) { @subject.editable? }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
rule { ~editable | anonymous }.prevent :edit_note
2018-03-17 18:26:18 +05:30
2017-09-10 17:25:29 +05:30
rule { is_author | admin }.enable :edit_note
rule { can?(:master_access) }.enable :edit_note
rule { is_author }.policy do
enable :read_note
enable :update_note
enable :admin_note
enable :resolve_note
end
rule { for_merge_request & is_noteable_author }.policy do
enable :resolve_note
2016-09-29 09:46:39 +05:30
end
end