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

28 lines
627 B
Ruby
Raw Normal View History

2016-09-29 09:46:39 +05:30
class PersonalSnippetPolicy < BasePolicy
def rules
can! :read_personal_snippet if @subject.public?
return unless @user
2017-08-17 22:00:37 +05:30
if @subject.public?
can! :comment_personal_snippet
end
2016-09-29 09:46:39 +05:30
if @subject.author == @user
can! :read_personal_snippet
can! :update_personal_snippet
2017-08-17 22:00:37 +05:30
can! :destroy_personal_snippet
2016-09-29 09:46:39 +05:30
can! :admin_personal_snippet
2017-08-17 22:00:37 +05:30
can! :comment_personal_snippet
end
unless @user.external?
can! :create_personal_snippet
2016-09-29 09:46:39 +05:30
end
if @subject.internal? && !@user.external?
can! :read_personal_snippet
2017-08-17 22:00:37 +05:30
can! :comment_personal_snippet
2016-09-29 09:46:39 +05:30
end
end
end