d9bb4230cc
Added visibility_level icons to project view (rather than just text). Added public projects to search results. Added ability to restrict visibility levels standard users can set.
42 lines
809 B
Ruby
42 lines
809 B
Ruby
# Gitlab::VisibilityLevel module
|
|
#
|
|
# Define allowed public modes that can be used for
|
|
# GitLab projects to determine project public mode
|
|
#
|
|
module Gitlab
|
|
module VisibilityLevel
|
|
PRIVATE = 0
|
|
INTERNAL = 10
|
|
PUBLIC = 20
|
|
|
|
class << self
|
|
def values
|
|
options.values
|
|
end
|
|
|
|
def options
|
|
{
|
|
'Private' => PRIVATE,
|
|
'Internal' => INTERNAL,
|
|
'Public' => PUBLIC
|
|
}
|
|
end
|
|
|
|
def allowed_for?(user, level)
|
|
user.is_admin? || !Gitlab.config.gitlab.restricted_visibility_levels.include?(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
|