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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
3fdcebfd
Commit
3fdcebfd
authored
Aug 16, 2016
by
http://jneen.net/
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trim dead code
parent
d87c1d55
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
81 deletions
+0
-81
app/models/ability.rb
app/models/ability.rb
+0
-81
No files found.
app/models/ability.rb
View file @
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
ProjectSnippet
then
project_snippet_abilities
(
user
,
subject
)
when
PersonalSnippet
then
personal_snippet_abilities
(
user
,
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
)
...
@@ -140,13 +139,6 @@ class Ability
...
@@ -140,13 +139,6 @@ class Ability
end
end
end
end
def
anonymous_commit_status_abilities
(
subject
)
rules
=
anonymous_project_abilities
(
subject
.
project
)
# If subject is Ci::Build which inherits from CommitStatus filter the abilities
rules
=
filter_build_abilities
(
rules
)
if
subject
.
is_a?
(
Ci
::
Build
)
rules
end
def
anonymous_group_abilities
(
subject
)
def
anonymous_group_abilities
(
subject
)
rules
=
[]
rules
=
[]
...
@@ -169,14 +161,6 @@ class Ability
...
@@ -169,14 +161,6 @@ class Ability
end
end
end
end
def
anonymous_project_snippet_abilities
(
snippet
)
if
snippet
.
public?
[
:read_project_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
...
@@ -248,46 +232,6 @@ class Ability
...
@@ -248,46 +232,6 @@ class Ability
rules
.
flatten
rules
.
flatten
end
end
[
:issue
,
:merge_request
].
each
do
|
name
|
define_method
"
#{
name
}
_abilities"
do
|
user
,
subject
|
rules
=
[]
if
subject
.
author
==
user
||
(
subject
.
respond_to?
(
:assignee
)
&&
subject
.
assignee
==
user
)
rules
+=
[
:"read_
#{
name
}
"
,
:"update_
#{
name
}
"
,
]
end
rules
+=
project_abilities
(
user
,
subject
.
project
)
rules
=
filter_confidential_issues_abilities
(
user
,
subject
,
rules
)
if
subject
.
is_a?
(
Issue
)
rules
end
end
def
note_abilities
(
user
,
note
)
rules
=
[]
if
note
.
author
==
user
rules
+=
[
:read_note
,
:update_note
,
:admin_note
,
:resolve_note
]
end
if
note
.
respond_to?
(
:project
)
&&
note
.
project
rules
+=
project_abilities
(
user
,
note
.
project
)
end
if
note
.
for_merge_request?
&&
note
.
noteable
.
author
==
user
rules
<<
:resolve_note
end
rules
end
def
personal_snippet_abilities
(
user
,
snippet
)
def
personal_snippet_abilities
(
user
,
snippet
)
rules
=
[]
rules
=
[]
...
@@ -306,24 +250,6 @@ class Ability
...
@@ -306,24 +250,6 @@ class Ability
rules
rules
end
end
def
project_snippet_abilities
(
user
,
snippet
)
rules
=
[]
if
snippet
.
author
==
user
||
user
.
admin?
rules
+=
[
:read_project_snippet
,
:update_project_snippet
,
:admin_project_snippet
]
end
if
snippet
.
public?
||
(
snippet
.
internal?
&&
!
user
.
external?
)
||
(
snippet
.
private?
&&
snippet
.
project
.
team
.
member?
(
user
))
rules
<<
:read_project_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
...
@@ -362,13 +288,6 @@ class Ability
...
@@ -362,13 +288,6 @@ class Ability
rules
rules
end
end
def
commit_status_abilities
(
user
,
subject
)
rules
=
project_abilities
(
user
,
subject
.
project
)
# If subject is Ci::Build which inherits from CommitStatus filter the abilities
rules
=
filter_build_abilities
(
rules
)
if
subject
.
is_a?
(
Ci
::
Build
)
rules
end
def
filter_build_abilities
(
rules
)
def
filter_build_abilities
(
rules
)
# If we can't read build we should also not have that
# If we can't read build we should also not have that
# ability when looking at this in context of commit_status
# ability when looking at this in context of commit_status
...
...
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