2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
class IssuablePolicy < BasePolicy
|
2017-09-10 17:25:29 +05:30
|
|
|
delegate { @subject.project }
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
condition(:locked, scope: :subject, score: 0) { @subject.discussion_locked? }
|
|
|
|
condition(:is_project_member) { @user && @subject.project && @subject.project.team.member?(@user) }
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
desc "User is the assignee or author"
|
|
|
|
condition(:assignee_or_author) do
|
|
|
|
@user && @subject.assignee_or_author?(@user)
|
|
|
|
end
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2019-01-03 12:48:30 +05:30
|
|
|
rule { can?(:guest_access) & assignee_or_author }.policy do
|
2017-09-10 17:25:29 +05:30
|
|
|
enable :read_issue
|
|
|
|
enable :update_issue
|
2018-11-20 20:47:30 +05:30
|
|
|
enable :reopen_issue
|
2017-09-10 17:25:29 +05:30
|
|
|
enable :read_merge_request
|
|
|
|
enable :update_merge_request
|
2019-05-18 00:54:41 +05:30
|
|
|
enable :reopen_merge_request
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
rule { locked & ~is_project_member }.policy do
|
|
|
|
prevent :create_note
|
|
|
|
prevent :admin_note
|
|
|
|
prevent :resolve_note
|
|
|
|
end
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|