diff options
author | Vinnie Okada <vokada@mrvinn.com> | 2015-03-01 08:06:46 -0700 |
---|---|---|
committer | Vinnie Okada <vokada@mrvinn.com> | 2015-03-07 13:11:08 -0700 |
commit | cacac147de2b317d02788c5da1cdc6010f00a340 (patch) | |
tree | 079ba9eb2adb0d34c47205bd778066dda7ce3d60 /app/services | |
parent | 3cf4359b00d13959741e8c4909112c21b021c86c (diff) | |
download | gitlab-ce-cacac147de2b317d02788c5da1cdc6010f00a340.tar.gz |
Move restricted visibility settings to the UI
Add checkboxes to the application settings page for restricted
visibility levels, and remove those settings from gitlab.yml.
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/base_service.rb | 4 | ||||
-rw-r--r-- | app/services/update_snippet_service.rb | 22 |
2 files changed, 22 insertions, 4 deletions
diff --git a/app/services/base_service.rb b/app/services/base_service.rb index 52ab29f1492..8b07d7a4361 100644 --- a/app/services/base_service.rb +++ b/app/services/base_service.rb @@ -31,10 +31,6 @@ class BaseService SystemHooksService.new end - def current_application_settings - ApplicationSetting.current - end - private def error(message, http_status = nil) diff --git a/app/services/update_snippet_service.rb b/app/services/update_snippet_service.rb new file mode 100644 index 00000000000..b7a719f2526 --- /dev/null +++ b/app/services/update_snippet_service.rb @@ -0,0 +1,22 @@ +class UpdateSnippetService < BaseService + attr_accessor :snippet + + def initialize(project = nil, user, snippet, params = {}) + super(project, user, params) + @snippet = snippet + end + + def execute + # check that user is allowed to set specified visibility_level + new_visibility = params[:visibility_level] + if new_visibility && new_visibility != snippet.visibility_level + unless can?(current_user, :change_visibility_level, snippet) && + Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility) + deny_visibility_level(snippet, new_visibility_level) + return snippet + end + end + + snippet.update_attributes(params) + end +end |