New upload review process partly finished
This commit is contained in:
parent
821364483e
commit
34d7eb649c
5 changed files with 70 additions and 24 deletions
|
|
@ -19,49 +19,45 @@ class PackagesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 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_image
|
||||
def upload_review
|
||||
# Remember the user by the cookie session
|
||||
create_user_token
|
||||
|
||||
@package = Package.find_by!(name: params[:name])
|
||||
# @images = params[:screenshot][:image]
|
||||
@images = []
|
||||
@valid_images = []
|
||||
@invalid_images = []
|
||||
|
||||
# Save the images already if they are valid.
|
||||
# params[:screenshot][:image].each do |img|
|
||||
# successful_upload_count = 0
|
||||
|
||||
params[:file].each do |img|
|
||||
params[:file].each do |img|
|
||||
new_screenshot = @package.screenshots.new(image: img)
|
||||
|
||||
# Check if the image was valid
|
||||
@images.push new_screenshot
|
||||
if new_screenshot.valid?
|
||||
new_screenshot.uploaderhash = session[:token]
|
||||
new_screenshot.uploaderip = session[:ip]
|
||||
new_screenshot.version = @package.version
|
||||
new_screenshot.save
|
||||
# successful_upload_count += 1
|
||||
Log.log "Screenshot #{new_screenshot.id} uploaded successfully."
|
||||
# else
|
||||
# errors = new_screenshot.errors[:image].join(' and ')
|
||||
# flash['alert'] = "Sorry - the image #{errors}"
|
||||
@valid_images.push new_screenshot
|
||||
else
|
||||
@invalid_images.push new_screenshot
|
||||
end
|
||||
|
||||
# if successful_upload_count > 0
|
||||
# flash['notice'] = "#{successful_upload_count} #{'screenshot'.pluralize(successful_upload_count)} uploaded successfully."
|
||||
# end
|
||||
end
|
||||
|
||||
# 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.
|
||||
# This was used in Debshots 1.x as the default upload method.
|
||||
# This method allows that old-style way to upload screenshots.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue