Writing log entry for each uploaded screenshot
This commit is contained in:
parent
be9113ea3f
commit
4dcbd365ff
1 changed files with 1 additions and 7 deletions
|
|
@ -32,10 +32,6 @@ class PackagesController < ApplicationController
|
||||||
params[:screenshot][:image].each do |img|
|
params[:screenshot][:image].each do |img|
|
||||||
new_screenshot = @package.screenshots.new(image: img)
|
new_screenshot = @package.screenshots.new(image: img)
|
||||||
|
|
||||||
# Check if the image is already present by checking its checksum.
|
|
||||||
# if @package.screenshots.find_by(image_fingerprint: new_screenshot.image_fingerprint)
|
|
||||||
# logger.error "Uploaded image exists already for package #{@package.name}. Rejecting."
|
|
||||||
# flash['alert'] = "Sorry - you uploaded a duplicate screenshot. I am ignoring it."
|
|
||||||
# Check if the image was valid
|
# Check if the image was valid
|
||||||
unless new_screenshot.valid?
|
unless new_screenshot.valid?
|
||||||
errors = new_screenshot.errors[:image].join(' and ')
|
errors = new_screenshot.errors[:image].join(' and ')
|
||||||
|
|
@ -43,14 +39,12 @@ class PackagesController < ApplicationController
|
||||||
else
|
else
|
||||||
new_screenshot.save
|
new_screenshot.save
|
||||||
successful_upload_count += 1
|
successful_upload_count += 1
|
||||||
|
Log.log "Screenshot #{new_screenshot.id} uploaded successfully."
|
||||||
end
|
end
|
||||||
|
|
||||||
if successful_upload_count > 0
|
if successful_upload_count > 0
|
||||||
flash['info'] = "#{successful_upload_count} #{'screenshot'.pluralize(successful_upload_count)} uploaded successfully."
|
flash['info'] = "#{successful_upload_count} #{'screenshot'.pluralize(successful_upload_count)} uploaded successfully."
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: add logging
|
|
||||||
# TODO: what do we do if the user uploads an invalid image? tell them?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to package_path
|
redirect_to package_path
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue