Screenshot upload process fixed and tested

This commit is contained in:
Christoph Haas 2018-08-17 09:21:32 +02:00
parent 125e9c8ee5
commit 9428d8d7dd
5 changed files with 60 additions and 3 deletions

View file

@ -56,7 +56,9 @@ class PackagesController < ApplicationController
new_screenshot.version = @package.version
new_screenshot.user = current_user
# TODO: must it be moderated first?
# Package is not approved by default. Approve automatically
# for authenticated users.
new_screenshot.approve! if current_user and not current_user.is_anonymous?
new_screenshot.save
Log.log "Screenshot #{new_screenshot.id} uploaded successfully from #{session[:ip]}. User has token #{session[:token]} or is #{current_user}"
@ -145,7 +147,7 @@ class PackagesController < ApplicationController
def approve_screenshot
@screenshot = Screenshot.find(params[:id])
@screenshot.approve_screenshot!
@screenshot.approve!
flash['notice'] = "Screenshot approved."
redirect_back(fallback_location: package_path(name: @screenshot.package.name))
end