Returning 404 if packages are not found
This commit is contained in:
parent
5ced4d3898
commit
473346d9f3
1 changed files with 10 additions and 11 deletions
|
|
@ -11,12 +11,11 @@ class PackagesController < ApplicationController
|
|||
end
|
||||
|
||||
def details
|
||||
@package = Package.find_by(name: params[:name])
|
||||
@package = Package.find_by!(name: params[:name])
|
||||
end
|
||||
|
||||
def upload
|
||||
raise "name not given" unless params[:name]
|
||||
@package = Package.find_by(name: params[:name])
|
||||
@package = Package.find_by!(name: params[:name])
|
||||
end
|
||||
|
||||
# POST target of the screenshots upload form.
|
||||
|
|
@ -25,7 +24,7 @@ class PackagesController < ApplicationController
|
|||
# Remember the user by the cookie session
|
||||
create_user_token
|
||||
|
||||
@package = Package.find_by(name: params[:name])
|
||||
@package = Package.find_by!(name: params[:name])
|
||||
|
||||
successful_upload_count = 0
|
||||
|
||||
|
|
@ -63,7 +62,7 @@ class PackagesController < ApplicationController
|
|||
# - description
|
||||
# - file
|
||||
def legacy_uploadfile
|
||||
@package = Package.find_by(name: params[:packagename])
|
||||
@package = Package.find_by!(name: params[:packagename])
|
||||
|
||||
new_screenshot = @package.screenshots.new(image: params[:file])
|
||||
|
||||
|
|
@ -82,7 +81,7 @@ class PackagesController < ApplicationController
|
|||
|
||||
def delete_screenshot
|
||||
# Is the user allowed to delete the screenshot?
|
||||
@screenshot = Screenshot.find(params[:id])
|
||||
@screenshot = Screenshot.find!(params[:id])
|
||||
|
||||
if user_can_alter_screenshot?
|
||||
@screenshot.destroy
|
||||
|
|
@ -94,7 +93,7 @@ class PackagesController < ApplicationController
|
|||
end
|
||||
|
||||
def approve_screenshot
|
||||
@screenshot = Screenshot.find(params[:id])
|
||||
@screenshot = Screenshot.find!(params[:id])
|
||||
@screenshot.approve_screenshot!
|
||||
flash['notice'] = "Screenshot approved."
|
||||
redirect_to :back
|
||||
|
|
@ -105,7 +104,7 @@ class PackagesController < ApplicationController
|
|||
# If the package is found but has no screenshots then it also returns a
|
||||
# dummy image along with status 404.
|
||||
def thumbnail
|
||||
@package = Package.find_by(name: params[:name])
|
||||
@package = Package.find_by!(name: params[:name])
|
||||
unless @package
|
||||
thumbnail404
|
||||
return
|
||||
|
|
@ -134,7 +133,7 @@ class PackagesController < ApplicationController
|
|||
# If the package is found but has no screenshots then it also returns a
|
||||
# dummy image along with status 404.
|
||||
def screenshot
|
||||
@package = Package.find_by(name: params[:name])
|
||||
@package = Package.find_by!(name: params[:name])
|
||||
unless @package
|
||||
screenshot404
|
||||
return
|
||||
|
|
@ -161,7 +160,7 @@ class PackagesController < ApplicationController
|
|||
# Receives a form with a simple text field 'description' so that users can update
|
||||
# the description of their screenshot.
|
||||
def update_screenshot_description
|
||||
@screenshot = Screenshot.find(params[:id])
|
||||
@screenshot = Screenshot.find!(params[:id])
|
||||
@screenshot.description = params[:description]
|
||||
@screenshot.save!
|
||||
flash['notice'] = "Description updated."
|
||||
|
|
@ -170,7 +169,7 @@ class PackagesController < ApplicationController
|
|||
|
||||
# Receive an anonymous report from a user to have a screenshot removed.
|
||||
def report_screenshot
|
||||
@screenshot = Screenshot.find(params[:id])
|
||||
@screenshot = Screenshot.find!(params[:id])
|
||||
@screenshot.delete_reason = params[:delete_reason]
|
||||
@screenshot.markedfordelete = true
|
||||
@screenshot.save!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue