Fix 404 for missing package

This commit is contained in:
Christoph Haas 2021-02-14 16:51:55 +01:00
parent 9a91229336
commit 3f0737c614
2 changed files with 10 additions and 9 deletions

View file

@ -19,16 +19,17 @@ class PackagesController < ApplicationController
# TODO: Get only screenshots visible to the user (admin or owner or approved) # TODO: Get only screenshots visible to the user (admin or owner or approved)
@package = Package.find_by(name: params[:name]) @package = Package.find_by(name: params[:name])
unless @package if @package.nil?
@packagename = params[:name] @packagename = params[:name]
render 'notfound' render 'notfound', status: 404
end else
# The first page of screenshots (if there are multiple at all) shows the # The first page of screenshots (if there are multiple at all) shows the
# first image twice as large. So the first page contains 5 images while # first image twice as large. So the first page contains 5 images while
# the second and further page contain 6 images. # the second and further page contain 6 images.
@page = params[:page] @page = params[:page]
@screenshots = screenshots_visible_to_user(@package).paginate(page: @page, per_page: 6) @screenshots = screenshots_visible_to_user(@package).paginate(page: @page, per_page: 6)
end
end end
# Show upload form for new images # Show upload form for new images

View file

@ -4,7 +4,7 @@ h1
p p
' I'm afraid but there is no package ' I'm afraid but there is no package
em =@package_name em =>@packagename
' in the database. It may be that a package that is available ' in the database. It may be that a package that is available
' in your favorite Linux distribution is not listed here. ' in your favorite Linux distribution is not listed here.
' If you think this is an error then feel free to leave ' If you think this is an error then feel free to leave