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

32 lines
863 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-08-16 14:10:34 -04:00
class IssuablePolicy < BasePolicy
delegate { @subject.project }
2016-08-16 14:10:34 -04:00
condition(:locked, scope: :subject, score: 0) { @subject.discussion_locked? }
condition(:is_project_member) { @user && @subject.project && @subject.project.team.member?(@user) }
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
rule { can?(:guest_access) & assignee_or_author }.policy do
enable :read_issue
enable :update_issue
enable :reopen_issue
enable :read_merge_request
enable :update_merge_request
enable :reopen_merge_request
2016-08-16 14:10:34 -04:00
end
rule { locked & ~is_project_member }.policy do
prevent :create_note
prevent :admin_note
prevent :resolve_note
prevent :award_emoji
end
2016-08-16 14:10:34 -04:00
end
IssuablePolicy.prepend_if_ee('EE::IssuablePolicy')