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
|
||||||
end
|
end
|
||||||
|
|
||||||
# Show upload form for new images.
|
# Show upload form for new images
|
||||||
# Display existing images for reference.
|
|
||||||
def upload
|
def upload
|
||||||
@package = Package.find_by!(name: params[:name])
|
@package = Package.find_by!(name: params[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST target of the screenshots upload form.
|
# POST target of the screenshots upload form.
|
||||||
# Receives uploaded images. Checks if they are valid. Asks for description.
|
# Receives uploaded images. Checks if they are valid. Asks for description.
|
||||||
def upload_review
|
def upload_receive
|
||||||
# Remember the user by the cookie session
|
# Send a cookie to remember the user by the cookie session.
|
||||||
create_user_token
|
create_user_token
|
||||||
|
|
||||||
@package = Package.find_by!(name: params[:name])
|
@package = Package.find_by!(name: params[:name])
|
||||||
|
|
@ -44,19 +43,23 @@ class PackagesController < ApplicationController
|
||||||
new_screenshot.uploaderip = session[:ip]
|
new_screenshot.uploaderip = session[:ip]
|
||||||
new_screenshot.version = @package.version
|
new_screenshot.version = @package.version
|
||||||
new_screenshot.save
|
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
|
@valid_images.push new_screenshot
|
||||||
else
|
else
|
||||||
@invalid_images.push new_screenshot
|
@invalid_images.push new_screenshot
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# if @invalid_images…
|
||||||
|
# ' #{image.image_file_name} (#{image.errors[:image].join(' and ')})
|
||||||
|
|
||||||
# redirect_to package_path
|
# redirect_to package_path
|
||||||
end
|
end
|
||||||
|
|
||||||
# Receive the descriptions from upload_review and update them
|
# Receive the descriptions from upload_review and update them
|
||||||
def upload_review2
|
def upload_review2
|
||||||
# R
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Legacy action to upload an image along with metadata.
|
# Legacy action to upload an image along with metadata.
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
' You are about to upload a screenshot for the #{@package.name}
|
' You are about to upload a screenshot for the #{@package.name}
|
||||||
' package. Thanks for your contribution.
|
' 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
|
.row
|
||||||
.small-6.columns
|
.small-6.columns
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@ Debshots::Application.routes.draw do
|
||||||
get 'upload', to: redirect('/packages'), as: :upload_legacy # legacy upload form
|
get 'upload', to: redirect('/packages'), as: :upload_legacy # legacy upload form
|
||||||
post 'uploadfile' => 'packages#legacy_uploadfile', name: /[^\/]+/
|
post 'uploadfile' => 'packages#legacy_uploadfile', name: /[^\/]+/
|
||||||
get 'upload/:name' => 'packages#upload', as: :upload, name: /[^\/]+/
|
get 'upload/:name' => 'packages#upload', as: :upload, name: /[^\/]+/
|
||||||
post 'upload_review/:name' => 'packages#upload_review', as: :upload_review, name: /[^\/]+/
|
post 'upload/:name' => 'packages#upload_receive', as: :upload_receive, name: /[^\/]+/
|
||||||
post 'upload_review2/:name' => 'packages#upload_review2', as: :upload_review2, name: /[^\/]+/
|
|
||||||
# TODO: "get" is probably the wrong method to delete a screenshot
|
# TODO: "get" is probably the wrong method to delete a screenshot
|
||||||
get 'delete_screenshot/:id' => 'packages#delete_screenshot', as: :delete_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
|
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