diff options
author | http://jneen.net/ <jneen@jneen.net> | 2016-08-16 23:08:14 +0300 |
---|---|---|
committer | http://jneen.net/ <jneen@jneen.net> | 2016-08-30 21:39:22 +0300 |
commit | d87c1d550f4870275432698e3cb19033c6855a15 (patch) | |
tree | ecc6559dd15a53e4ca4f0ce353479db6d5a573fb /app/policies/project_snippet_policy.rb | |
parent | 3656d3b88a01a50a5eaf66a16b6ac47d3c58352c (diff) |
port notes and project snippets
Diffstat (limited to 'app/policies/project_snippet_policy.rb')
-rw-r--r-- | app/policies/project_snippet_policy.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/policies/project_snippet_policy.rb b/app/policies/project_snippet_policy.rb new file mode 100644 index 00000000000..57acccfafd9 --- /dev/null +++ b/app/policies/project_snippet_policy.rb @@ -0,0 +1,20 @@ +class ProjectSnippetPolicy < BasePolicy + def rules + can! :read_project_snippet if @subject.public? + return unless @user + + if @user && @subject.author == @user || @user.admin? + can! :read_project_snippet + can! :update_project_snippet + can! :admin_project_snippet + end + + if @subject.internal? && !@user.external? + can! :read_project_snippet + end + + if @subject.private? && @subject.project.team.member?(@user) + can! :read_project_snippet + end + end +end |