debian-mirror-gitlab/app/services/create_snippet_service.rb

21 lines
462 B
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class CreateSnippetService < BaseService
def execute
if project.nil?
snippet = PersonalSnippet.new(params)
else
snippet = project.snippets.build(params)
end
unless Gitlab::VisibilityLevel.allowed_for?(current_user,
params[:visibility_level])
deny_visibility_level(snippet)
return snippet
end
snippet.author = current_user
snippet.save
snippet
end
end