port notes and project snippets
This commit is contained in:
parent
3656d3b88a
commit
d87c1d550f
2 changed files with 39 additions and 0 deletions
19
app/policies/note_policy.rb
Normal file
19
app/policies/note_policy.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
class NotePolicy < BasePolicy
|
||||
def rules
|
||||
delegate! @subject.project
|
||||
|
||||
return unless @user
|
||||
|
||||
if @subject.author == @user
|
||||
can! :read_note
|
||||
can! :update_note
|
||||
can! :admin_note
|
||||
can! :resolve_note
|
||||
end
|
||||
|
||||
if @subject.for_merge_request? &&
|
||||
@subject.noteable.author == @user
|
||||
can! :resolve_note
|
||||
end
|
||||
end
|
||||
end
|
20
app/policies/project_snippet_policy.rb
Normal file
20
app/policies/project_snippet_policy.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue