2016-08-16 16:08:14 -04:00
|
|
|
class ProjectSnippetPolicy < BasePolicy
|
|
|
|
def rules
|
|
|
|
can! :read_project_snippet if @subject.public?
|
|
|
|
return unless @user
|
|
|
|
|
2017-02-05 13:54:19 -05:00
|
|
|
if @user && (@subject.author == @user || @user.admin?)
|
2016-08-16 16:08:14 -04:00
|
|
|
can! :read_project_snippet
|
|
|
|
can! :update_project_snippet
|
|
|
|
can! :admin_project_snippet
|
|
|
|
end
|
|
|
|
|
|
|
|
if @subject.internal? && !@user.external?
|
|
|
|
can! :read_project_snippet
|
|
|
|
end
|
|
|
|
|
2017-04-28 18:06:27 -04:00
|
|
|
if @subject.project.team.member?(@user)
|
2016-08-16 16:08:14 -04:00
|
|
|
can! :read_project_snippet
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|