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:
Diffstat (limited to 'lib/gitlab/visibility_level.rb')
-rw-r--r--lib/gitlab/visibility_level.rb64
1 files changed, 0 insertions, 64 deletions
diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb
deleted file mode 100644
index 582fc759efd..00000000000
--- a/lib/gitlab/visibility_level.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-# Gitlab::VisibilityLevel module
-#
-# Define allowed public modes that can be used for
-# GitLab projects to determine project public mode
-#
-module Gitlab
- module VisibilityLevel
- extend CurrentSettings
-
- PRIVATE = 0 unless const_defined?(:PRIVATE)
- INTERNAL = 10 unless const_defined?(:INTERNAL)
- PUBLIC = 20 unless const_defined?(:PUBLIC)
-
- class << self
- def values
- options.values
- end
-
- def options
- {
- 'Private' => PRIVATE,
- 'Internal' => INTERNAL,
- 'Public' => PUBLIC
- }
- end
-
- def allowed_for?(user, level)
- user.is_admin? || allowed_level?(level.to_i)
- end
-
- # Return true if the specified level is allowed for the current user.
- # Level should be a numeric value, e.g. `20`.
- def allowed_level?(level)
- valid_level?(level) && non_restricted_level?(level)
- end
-
- def non_restricted_level?(level)
- restricted_levels = current_application_settings.restricted_visibility_levels
-
- if restricted_levels.nil?
- true
- else
- !restricted_levels.include?(level)
- end
- end
-
- def valid_level?(level)
- options.has_value?(level)
- end
- end
-
- def private?
- visibility_level_field == PRIVATE
- end
-
- def internal?
- visibility_level_field == INTERNAL
- end
-
- def public?
- visibility_level_field == PUBLIC
- end
- end
-end