2018-07-24 06:00:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-16 14:10:34 -04:00
|
|
|
class IssuablePolicy < BasePolicy
|
2017-04-06 17:06:42 -04:00
|
|
|
delegate { @subject.project }
|
2016-08-16 14:10:34 -04:00
|
|
|
|
2017-09-01 08:03:57 -04:00
|
|
|
condition(:locked, scope: :subject, score: 0) { @subject.discussion_locked? }
|
2017-08-30 10:57:50 -04:00
|
|
|
condition(:is_project_member) { @user && @subject.project && @subject.project.team.member?(@user) }
|
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
desc "User is the assignee or author"
|
|
|
|
condition(:assignee_or_author) do
|
|
|
|
@user && @subject.assignee_or_author?(@user)
|
|
|
|
end
|
2016-08-16 14:10:34 -04:00
|
|
|
|
2018-12-07 10:48:38 -05:00
|
|
|
rule { can?(:guest_access) & assignee_or_author }.policy do
|
2017-04-06 17:06:42 -04:00
|
|
|
enable :read_issue
|
|
|
|
enable :update_issue
|
2018-08-19 15:43:41 -04:00
|
|
|
enable :reopen_issue
|
2017-04-06 17:06:42 -04:00
|
|
|
enable :read_merge_request
|
|
|
|
enable :update_merge_request
|
2019-03-08 03:34:20 -05:00
|
|
|
enable :reopen_merge_request
|
2016-08-16 14:10:34 -04:00
|
|
|
end
|
2017-08-30 10:57:50 -04:00
|
|
|
|
2017-09-01 08:03:57 -04:00
|
|
|
rule { locked & ~is_project_member }.policy do
|
|
|
|
prevent :create_note
|
|
|
|
prevent :admin_note
|
|
|
|
prevent :resolve_note
|
2020-08-24 17:10:17 -04:00
|
|
|
prevent :award_emoji
|
2017-09-01 08:03:57 -04:00
|
|
|
end
|
2016-08-16 14:10:34 -04:00
|
|
|
end
|