Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-12-20 18:19:54 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2017-12-29 13:15:26 +0300
commit0618487906a8b44eea7cb858aff45a5d5ea4cfff (patch)
treec6620ca499bba21b35a513ff195260478bd31333 /lib/gitlab/visibility_level.rb
parent723d788fbef90b270cce1ca1d4bc228c54041eaa (diff)
Forking a project to a namespace with lower visibility.
In this case the project will get the minimum between both visibilities. If that visibility is restricted, then a lower level will be picked.
Diffstat (limited to 'lib/gitlab/visibility_level.rb')
-rw-r--r--lib/gitlab/visibility_level.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb
index 11472ce6cce..6ced06a863d 100644
--- a/lib/gitlab/visibility_level.rb
+++ b/lib/gitlab/visibility_level.rb
@@ -57,11 +57,17 @@ module Gitlab
}
end
- def highest_allowed_level
+ def allowed_levels
restricted_levels = current_application_settings.restricted_visibility_levels
- allowed_levels = self.values - restricted_levels
- allowed_levels.max || PRIVATE
+ self.values - restricted_levels
+ end
+
+ def closest_allowed_level(target_level)
+ highest_allowed_level = allowed_levels.select { |level| level <= target_level }.max
+
+ # If all levels are restricted, fall back to PRIVATE
+ highest_allowed_level || PRIVATE
end
def allowed_for?(user, level)