diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-29 10:54:35 +0300 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-06-07 08:52:41 +0300 |
commit | 2e311d9d1aac58bbd9c7d6c97c7cbcccf2715347 (patch) | |
tree | 04555ee940d5488ef6d44c5ad3afa0688cd6c1c5 /app/controllers | |
parent | 4464c22d6d23d893494682d309aec3fb31c11ae3 (diff) |
Support uploads for newly created personal snippets
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/snippets_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/uploads_controller.rb | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 1334f7daa44..6c25f59ccbb 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -45,7 +45,7 @@ class SnippetsController < ApplicationController @snippet = CreateSnippetService.new(nil, current_user, create_params).execute - move_temporary_files if params[:files] + move_temporary_files if @snippet.valid? && params[:files] recaptcha_check_with_fallback { render :new } end diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 5cb3de3d4f5..dc882b17143 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -17,6 +17,8 @@ class UploadsController < ApplicationController end def authorize_access! + return nil unless model + authorized = case model when Note @@ -35,7 +37,7 @@ class UploadsController < ApplicationController end def authorize_create_access! - return unless model + return nil unless model # for now we support only personal snippets comments authorized = can?(current_user, :comment_personal_snippet, model) @@ -77,7 +79,12 @@ class UploadsController < ApplicationController def uploader return @uploader if defined?(@uploader) - if model.is_a?(PersonalSnippet) + case model + when nil + @uploader = PersonalFileUploader.new(nil, params[:secret]) + + @uploader.retrieve_from_store!(params[:filename]) + when PersonalSnippet @uploader = PersonalFileUploader.new(model, params[:secret]) @uploader.retrieve_from_store!(params[:filename]) |