Commit 4016c535 authored by http://jneen.net/'s avatar http://jneen.net/

port personal snippets

parent 3fdcebfd
......@@ -73,7 +73,6 @@ class Ability
def abilities_by_subject_class(user:, subject:)
case subject
when PersonalSnippet then personal_snippet_abilities(user, subject)
when Group then group_abilities(user, subject)
when Namespace then namespace_abilities(user, subject)
when GroupMember then group_member_abilities(user, subject)
......@@ -87,11 +86,7 @@ class Ability
# List of possible abilities for anonymous user
def anonymous_abilities(subject)
if subject.is_a?(PersonalSnippet)
anonymous_personal_snippet_abilities(subject)
elsif subject.is_a?(ProjectSnippet)
anonymous_project_snippet_abilities(subject)
elsif subject.respond_to?(:project)
if subject.respond_to?(:project)
ProjectPolicy.abilities(nil, subject.project)
elsif subject.is_a?(Group) || subject.respond_to?(:group)
anonymous_group_abilities(subject)
......@@ -153,14 +148,6 @@ class Ability
rules
end
def anonymous_personal_snippet_abilities(snippet)
if snippet.public?
[:read_personal_snippet]
else
[]
end
end
def anonymous_user_abilities
[:read_user] unless restricted_public_level?
end
......@@ -232,24 +219,6 @@ class Ability
rules.flatten
end
def personal_snippet_abilities(user, snippet)
rules = []
if snippet.author == user
rules += [
:read_personal_snippet,
:update_personal_snippet,
:admin_personal_snippet
]
end
if snippet.public? || (snippet.internal? && !user.external?)
rules << :read_personal_snippet
end
rules
end
def group_member_abilities(user, subject)
rules = []
target_user = subject.user
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment