debian-mirror-gitlab/app/policies/personal_snippet_policy.rb
2017-08-17 22:00:37 +05:30

27 lines
627 B
Ruby

class PersonalSnippetPolicy < BasePolicy
def rules
can! :read_personal_snippet if @subject.public?
return unless @user
if @subject.public?
can! :comment_personal_snippet
end
if @subject.author == @user
can! :read_personal_snippet
can! :update_personal_snippet
can! :destroy_personal_snippet
can! :admin_personal_snippet
can! :comment_personal_snippet
end
unless @user.external?
can! :create_personal_snippet
end
if @subject.internal? && !@user.external?
can! :read_personal_snippet
can! :comment_personal_snippet
end
end
end