BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
27 deletions
+21
-27
update_visibility_level.rb
app/services/concerns/update_visibility_level.rb
+15
-0
update_service.rb
app/services/groups/update_service.rb
+3
-10
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
class
UpdateService
<
Groups
::
BaseService
include
UpdateVisibilityLevel
def
execute
reject_parent_id!
# check that user is allowed to set specified 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
visibility_level_allowed?
(
group
,
params
[
:visibility_level
])
return
false
unless
valid_share_with_group_lock_change?
...
...
app/services/projects/update_service.rb
View file @
9fc10b1b
module
Projects
class
UpdateService
<
BaseService
include
UpdateVisibilityLevel
def
execute
unless
visibility_level_allowed?
unless
visibility_level_allowed?
(
project
,
params
[
:visibility_level
])
return
error
(
'New visibility level not allowed!'
)
end
...
...
@@ -28,22 +30,6 @@ module Projects
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?
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