BigW Consortium Gitlab

Commit 9e1db139 by Tomasz Maczukin

Move level_name resolving to Gitlan::VisibilityLevel

parent d2846293
...@@ -39,10 +39,7 @@ class BaseService ...@@ -39,10 +39,7 @@ class BaseService
def deny_visibility_level(model, denied_visibility_level = nil) def deny_visibility_level(model, denied_visibility_level = nil)
denied_visibility_level ||= model.visibility_level denied_visibility_level ||= model.visibility_level
level_name = 'Unknown' level_name = Gitlab::VisibilityLevel.level_name(denied_visibility_level)
Gitlab::VisibilityLevel.options.each do |name, level|
level_name = name if level == denied_visibility_level
end
model.errors.add( model.errors.add(
:visibility_level, :visibility_level,
......
...@@ -51,6 +51,15 @@ module Gitlab ...@@ -51,6 +51,15 @@ module Gitlab
def allowed_fork_levels(origin_level) def allowed_fork_levels(origin_level)
[PRIVATE, INTERNAL, PUBLIC].select{ |level| level <= origin_level } [PRIVATE, INTERNAL, PUBLIC].select{ |level| level <= origin_level }
end end
def level_name(level)
level_name = 'Unknown'
options.each do |name, lvl|
level_name = name if lvl == level
end
level_name
end
end end
def private? def private?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment