summaryrefslogtreecommitdiff
path: root/app/helpers/visibility_level_helper.rb
diff options
context:
space:
mode:
authorVinnie Okada <vokada@mrvinn.com>2015-04-25 23:01:52 -0600
committerVinnie Okada <vokada@mrvinn.com>2015-04-26 07:48:19 -0600
commitbd557e4b64a733f4be64b8cf36b8a551d8e8bab7 (patch)
treebbcfbe5bd73b157755254f9270c0601be4ab74f0 /app/helpers/visibility_level_helper.rb
parent439b9f50af3168d33169a4cd25b59e45ea46dc62 (diff)
downloadgitlab-ce-bd557e4b64a733f4be64b8cf36b8a551d8e8bab7.tar.gz
Add new admin settings
Add new global application settings for default project and snippet visibility levels.
Diffstat (limited to 'app/helpers/visibility_level_helper.rb')
-rw-r--r--app/helpers/visibility_level_helper.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/app/helpers/visibility_level_helper.rb b/app/helpers/visibility_level_helper.rb
index 0d573e72a80..66a1383d61b 100644
--- a/app/helpers/visibility_level_helper.rb
+++ b/app/helpers/visibility_level_helper.rb
@@ -10,7 +10,21 @@ module VisibilityLevelHelper
end
end
- def visibility_level_description(level)
+ # Return the description for the +level+ argument.
+ #
+ # +level+ One of the Gitlab::VisibilityLevel constants
+ # +form_model+ Either a model object (Project, Snippet, etc.) or the name of
+ # a Project or Snippet class.
+ def visibility_level_description(level, form_model)
+ case form_model.is_a?(String) ? form_model : form_model.class.name
+ when 'PersonalSnippet', 'ProjectSnippet', 'Snippet'
+ snippet_visibility_level_description(level)
+ when 'Project'
+ project_visibility_level_description(level)
+ end
+ end
+
+ def project_visibility_level_description(level)
capture_haml do
haml_tag :span do
case level
@@ -64,4 +78,12 @@ module VisibilityLevelHelper
return [] if current_user.is_admin? && !show_all
current_application_settings.restricted_visibility_levels || []
end
+
+ def default_project_visibility
+ current_application_settings.default_project_visibility
+ end
+
+ def default_snippet_visibility
+ current_application_settings.default_snippet_visibility
+ end
end