Routing changed to accomodate new upload workflow
This commit is contained in:
parent
bbccbfcc20
commit
0e02b70213
3 changed files with 11 additions and 9 deletions
|
|
@ -19,16 +19,15 @@ class PackagesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# Show upload form for new images.
|
||||
# Display existing images for reference.
|
||||
# Show upload form for new images
|
||||
def upload
|
||||
@package = Package.find_by!(name: params[:name])
|
||||
end
|
||||
|
||||
# POST target of the screenshots upload form.
|
||||
# Receives uploaded images. Checks if they are valid. Asks for description.
|
||||
def upload_review
|
||||
# Remember the user by the cookie session
|
||||
def upload_receive
|
||||
# Send a cookie to remember the user by the cookie session.
|
||||
create_user_token
|
||||
|
||||
@package = Package.find_by!(name: params[:name])
|
||||
|
|
@ -44,19 +43,23 @@ class PackagesController < ApplicationController
|
|||
new_screenshot.uploaderip = session[:ip]
|
||||
new_screenshot.version = @package.version
|
||||
new_screenshot.save
|
||||
Log.log "Screenshot #{new_screenshot.id} uploaded successfully."
|
||||
Log.log "Screenshot #{new_screenshot.id} uploaded successfully from #{session[:ip]}. User has token #{session[:token]}"
|
||||
@valid_images.push new_screenshot
|
||||
else
|
||||
@invalid_images.push new_screenshot
|
||||
end
|
||||
end
|
||||
|
||||
# TODO
|
||||
# if @invalid_images…
|
||||
# ' #{image.image_file_name} (#{image.errors[:image].join(' and ')})
|
||||
|
||||
# redirect_to package_path
|
||||
end
|
||||
|
||||
# Receive the descriptions from upload_review and update them
|
||||
def upload_review2
|
||||
# R
|
||||
|
||||
end
|
||||
|
||||
# Legacy action to upload an image along with metadata.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
' You are about to upload a screenshot for the #{@package.name}
|
||||
' package. Thanks for your contribution.
|
||||
|
||||
= form_for :screenshot, url: upload_review_path, html: { multipart: true, id: 'file-form' } do |f|
|
||||
= form_for :screenshot, url: upload_receive_path, html: { multipart: true, id: 'file-form' } do |f|
|
||||
|
||||
.row
|
||||
.small-6.columns
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ Debshots::Application.routes.draw do
|
|||
get 'upload', to: redirect('/packages'), as: :upload_legacy # legacy upload form
|
||||
post 'uploadfile' => 'packages#legacy_uploadfile', name: /[^\/]+/
|
||||
get 'upload/:name' => 'packages#upload', as: :upload, name: /[^\/]+/
|
||||
post 'upload_review/:name' => 'packages#upload_review', as: :upload_review, name: /[^\/]+/
|
||||
post 'upload_review2/:name' => 'packages#upload_review2', as: :upload_review2, name: /[^\/]+/
|
||||
post 'upload/:name' => 'packages#upload_receive', as: :upload_receive, name: /[^\/]+/
|
||||
# TODO: "get" is probably the wrong method to delete a screenshot
|
||||
get 'delete_screenshot/:id' => 'packages#delete_screenshot', as: :delete_screenshot
|
||||
post 'update_screenshot_description/:name/:id' => 'packages#update_screenshot_description', as: :update_screenshot_description
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue