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
9fc10b1b
Commit
9fc10b1b
authored
Sep 01, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dry up method for code climate
parent
c2c6c4c6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
27 deletions
+21
-27
app/services/concerns/update_visibility_level.rb
app/services/concerns/update_visibility_level.rb
+15
-0
app/services/groups/update_service.rb
app/services/groups/update_service.rb
+3
-10
app/services/projects/update_service.rb
app/services/projects/update_service.rb
+3
-17
No files found.
app/services/concerns/update_visibility_level.rb
0 → 100644
View file @
9fc10b1b
module
UpdateVisibilityLevel
def
visibility_level_allowed?
(
target
,
new_visibility
)
# check that user is allowed to set specified visibility_level
if
new_visibility
&&
new_visibility
.
to_i
!=
target
.
visibility_level
unless
can?
(
current_user
,
:change_visibility_level
,
target
)
&&
Gitlab
::
VisibilityLevel
.
allowed_for?
(
current_user
,
new_visibility
)
deny_visibility_level
(
target
,
new_visibility
)
return
false
end
end
true
end
end
app/services/groups/update_service.rb
View file @
9fc10b1b
module
Groups
module
Groups
class
UpdateService
<
Groups
::
BaseService
class
UpdateService
<
Groups
::
BaseService
include
UpdateVisibilityLevel
def
execute
def
execute
reject_parent_id!
reject_parent_id!
# check that user is allowed to set specified visibility_level
return
false
unless
visibility_level_allowed?
(
group
,
params
[
:visibility_level
])
new_visibility
=
params
[
:visibility_level
]
if
new_visibility
&&
new_visibility
.
to_i
!=
group
.
visibility_level
unless
can?
(
current_user
,
:change_visibility_level
,
group
)
&&
Gitlab
::
VisibilityLevel
.
allowed_for?
(
current_user
,
new_visibility
)
deny_visibility_level
(
group
,
new_visibility
)
return
false
end
end
return
false
unless
valid_share_with_group_lock_change?
return
false
unless
valid_share_with_group_lock_change?
...
...
app/services/projects/update_service.rb
View file @
9fc10b1b
module
Projects
module
Projects
class
UpdateService
<
BaseService
class
UpdateService
<
BaseService
include
UpdateVisibilityLevel
def
execute
def
execute
unless
visibility_level_allowed?
unless
visibility_level_allowed?
(
project
,
params
[
:visibility_level
])
return
error
(
'New visibility level not allowed!'
)
return
error
(
'New visibility level not allowed!'
)
end
end
...
@@ -28,22 +30,6 @@ module Projects
...
@@ -28,22 +30,6 @@ module Projects
private
private
def
visibility_level_allowed?
# check that user is allowed to set specified visibility_level
new_visibility
=
params
[
:visibility_level
]
if
new_visibility
&&
new_visibility
.
to_i
!=
project
.
visibility_level
unless
can?
(
current_user
,
:change_visibility_level
,
project
)
&&
Gitlab
::
VisibilityLevel
.
allowed_for?
(
current_user
,
new_visibility
)
deny_visibility_level
(
project
,
new_visibility
)
return
false
end
end
true
end
def
renaming_project_with_container_registry_tags?
def
renaming_project_with_container_registry_tags?
new_path
=
params
[
:path
]
new_path
=
params
[
:path
]
...
...
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