Legacy upload method for images from Debshots 1.x implemented
This commit is contained in:
parent
6feaa53920
commit
bb79e109c2
3 changed files with 35 additions and 1 deletions
|
|
@ -1,5 +1,7 @@
|
|||
class PackagesController < ApplicationController
|
||||
|
||||
protect_from_forgery :except => :legacy_uploadfile
|
||||
|
||||
def list
|
||||
@packages = query_packages
|
||||
@packages = @packages.paginate(page: params[:page], per_page: 6)
|
||||
|
|
@ -51,6 +53,34 @@ class PackagesController < ApplicationController
|
|||
redirect_to package_path
|
||||
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.
|
||||
# It is probably used by screenshotting tools.
|
||||
#
|
||||
# Parameters:
|
||||
# - packagename
|
||||
# - version
|
||||
# - description
|
||||
# - file
|
||||
def legacy_uploadfile
|
||||
@package = Package.find_by(name: params[:packagename])
|
||||
|
||||
new_screenshot = @package.screenshots.new(image: params[:file])
|
||||
|
||||
# Check if the image was valid
|
||||
if new_screenshot.valid?
|
||||
# new_screenshot.uploaderhash = session[:token]
|
||||
new_screenshot.uploaderip = session[:ip]
|
||||
new_screenshot.save
|
||||
Log.log "Screenshot #{new_screenshot.id} uploaded successfully from legacy upload form."
|
||||
redirect_to package_path(params[:packagename])
|
||||
else
|
||||
Log.log "Screenshot upload rejected. Errors: #{new_screenshot.errors.to_a}"
|
||||
head :not_acceptable
|
||||
end
|
||||
end
|
||||
|
||||
def delete_screenshot
|
||||
# Is the user allowed to delete the screenshot?
|
||||
@screenshot = Screenshot.find(params[:id])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue