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

port personal snippets

parent 3fdcebfd
...@@ -73,7 +73,6 @@ class Ability ...@@ -73,7 +73,6 @@ class Ability
def abilities_by_subject_class(user:, subject:) def abilities_by_subject_class(user:, subject:)
case subject case subject
when PersonalSnippet then personal_snippet_abilities(user, subject)
when Group then group_abilities(user, subject) when Group then group_abilities(user, subject)
when Namespace then namespace_abilities(user, subject) when Namespace then namespace_abilities(user, subject)
when GroupMember then group_member_abilities(user, subject) when GroupMember then group_member_abilities(user, subject)
...@@ -87,11 +86,7 @@ class Ability ...@@ -87,11 +86,7 @@ class Ability
# List of possible abilities for anonymous user # List of possible abilities for anonymous user
def anonymous_abilities(subject) def anonymous_abilities(subject)
if subject.is_a?(PersonalSnippet) if subject.respond_to?(:project)
anonymous_personal_snippet_abilities(subject)
elsif subject.is_a?(ProjectSnippet)
anonymous_project_snippet_abilities(subject)
elsif subject.respond_to?(:project)
ProjectPolicy.abilities(nil, subject.project) ProjectPolicy.abilities(nil, subject.project)
elsif subject.is_a?(Group) || subject.respond_to?(:group) elsif subject.is_a?(Group) || subject.respond_to?(:group)
anonymous_group_abilities(subject) anonymous_group_abilities(subject)
...@@ -153,14 +148,6 @@ class Ability ...@@ -153,14 +148,6 @@ class Ability
rules rules
end end
def anonymous_personal_snippet_abilities(snippet)
if snippet.public?
[:read_personal_snippet]
else
[]
end
end
def anonymous_user_abilities def anonymous_user_abilities
[:read_user] unless restricted_public_level? [:read_user] unless restricted_public_level?
end end
...@@ -232,24 +219,6 @@ class Ability ...@@ -232,24 +219,6 @@ class Ability
rules.flatten rules.flatten
end 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) def group_member_abilities(user, subject)
rules = [] rules = []
target_user = subject.user 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