Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4016c535
Commit
4016c535
authored
Aug 16, 2016
by
http://jneen.net/
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
port personal snippets
parent
3fdcebfd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
32 deletions
+1
-32
app/models/ability.rb
app/models/ability.rb
+1
-32
No files found.
app/models/ability.rb
View file @
4016c535
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment