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
Kazuhiko Shiozaki
gitlab-ce
Commits
083d4604
Commit
083d4604
authored
Jun 26, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change dynamic abilities to new format
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
d63371ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
13 deletions
+9
-13
app/models/ability.rb
app/models/ability.rb
+7
-11
app/services/update_snippet_service.rb
app/services/update_snippet_service.rb
+2
-2
No files found.
app/models/ability.rb
View file @
083d4604
...
...
@@ -246,20 +246,16 @@ class Ability
[
:issue
,
:note
,
:project_snippet
,
:personal_snippet
,
:merge_request
].
each
do
|
name
|
define_method
"
#{
name
}
_abilities"
do
|
user
,
subject
|
if
subject
.
author
==
user
||
user
.
is_admin?
rules
=
[
if
user
.
is_admin?
[
:"read_
#{
name
}
"
,
:"write_
#{
name
}
"
,
:"modify_
#{
name
}
"
,
:"update_
#{
name
}
"
,
:"admin_
#{
name
}
"
]
rules
.
push
(
:change_visibility_level
)
if
subject
.
is_a?
(
Snippet
)
rules
elsif
subject
.
respond_to?
(
:assignee
)
&&
subject
.
assignee
==
user
elsif
subject
.
author
==
user
||
(
subject
.
respond_to?
(
:assignee
)
&&
subject
.
assignee
==
user
)
[
:"read_
#{
name
}
"
,
:"write_
#{
name
}
"
,
:"modify_
#{
name
}
"
,
:"update_
#{
name
}
"
,
]
else
if
subject
.
respond_to?
(
:project
)
&&
subject
.
project
...
...
@@ -299,8 +295,8 @@ class Ability
def
named_abilities
(
name
)
[
:"read_
#{
name
}
"
,
:"
wri
te_
#{
name
}
"
,
:"
modify
_
#{
name
}
"
,
:"
crea
te_
#{
name
}
"
,
:"
update
_
#{
name
}
"
,
:"admin_
#{
name
}
"
]
end
...
...
app/services/update_snippet_service.rb
View file @
083d4604
...
...
@@ -9,9 +9,9 @@ class UpdateSnippetService < BaseService
def
execute
# check that user is allowed to set specified visibility_level
new_visibility
=
params
[
:visibility_level
]
if
new_visibility
&&
new_visibility
.
to_i
!=
snippet
.
visibility_level
unless
can?
(
current_user
,
:change_visibility_level
,
snippet
)
&&
Gitlab
::
VisibilityLevel
.
allowed_for?
(
current_user
,
new_visibility
)
unless
Gitlab
::
VisibilityLevel
.
allowed_for?
(
current_user
,
new_visibility
)
deny_visibility_level
(
snippet
,
new_visibility
)
return
snippet
end
...
...
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