Avoid displaying unapproved screenshots in Any view
This commit is contained in:
parent
ce9e1d8877
commit
7227f769c0
2 changed files with 6 additions and 2 deletions
|
|
@ -288,7 +288,7 @@ class PackagesController < ApplicationController
|
|||
|
||||
# Return packages matching the criteria given by parameters
|
||||
def query_packages
|
||||
# Eager load the screenshots to avoid N+1 queries to check Screenshot.accessibly_by later
|
||||
# Eager load the screenshots to avoid N+1 queries to check Screenshot.accessible_by later
|
||||
packages = Package.includes(:screenshots).order(visits: :desc)
|
||||
|
||||
# text search
|
||||
|
|
@ -305,6 +305,10 @@ class PackagesController < ApplicationController
|
|||
when 'without'
|
||||
packages = packages.without_screenshots
|
||||
logger.debug 'Limiting packages to those without screenshots'
|
||||
else
|
||||
packages = packages.where(screenshots: Screenshot.accessible_by(current_ability, :view)).or(
|
||||
packages.without_screenshots)
|
||||
|
||||
end
|
||||
|
||||
return packages
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
.small-7.medium-7.cell
|
||||
/ Left column contains images
|
||||
|
||||
- if @screenshots.length > 0
|
||||
- if @screenshots.any?
|
||||
= render(partial: 'packages/paginator', locals: {items: @screenshots})
|
||||
.grid-x.grid-margin-x.medium-up-1.large-up-2 data-equalizer=true data-equalize-on="medium"
|
||||
- @screenshots.each do |screenshot|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue