add personal snippets and project members

This commit is contained in:
http://jneen.net/ 2016-08-16 16:46:35 -07:00
parent 9a0ea13501
commit 29059c2e9c
2 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,16 @@
class PersonalSnippetPolicy < BasePolicy
def rules
can! :read_personal_snippet if @subject.public?
return unless @user
if @subject.author == @user
can! :read_personal_snippet
can! :update_personal_snippet
can! :admin_personal_snippet
end
if @subject.internal? && !@user.external?
can! :read_personal_snippet
end
end
end

View file

@ -0,0 +1,22 @@
class ProjectMemberPolicy < BasePolicy
def rules
# anonymous users have no abilities here
return unless @user
target_user = @subject.user
project = @subject.project
return if target_user == project.owner
can_manage = Ability.allowed?(@user, :admin_project_member, project)
if can_manage
can! :update_project_member
can! :destroy_project_member
end
if @user == target_user
can! :destroy_project_member
end
end
end