Moved screenshots_visible_to_user to model
This commit is contained in:
parent
1cc189ccdc
commit
ba5a89a26a
3 changed files with 12 additions and 13 deletions
|
|
@ -1,13 +1,2 @@
|
|||
module PackagesHelper
|
||||
# Return a query of all screenshots that the current user may see
|
||||
# Consists of:
|
||||
# - approved (public) screenshots
|
||||
# - screenshots uploaded by the user (determined by cookie session)
|
||||
def screenshots_visible_to_user
|
||||
self.screenshots.where(
|
||||
# "approved=true"
|
||||
"approved=true OR uploaderhash=?", session[:token]
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -37,4 +37,14 @@ class Package < ActiveRecord::Base
|
|||
self.screenshots.find_by(approved: true)
|
||||
end
|
||||
|
||||
# Return a query of all screenshots that the current user may see
|
||||
# Consists of:
|
||||
# - approved (public) screenshots
|
||||
# - screenshots uploaded by the user (determined by cookie session)
|
||||
def screenshots_visible_to_user(token)
|
||||
self.screenshots.where(
|
||||
# "approved=true"
|
||||
"approved=true OR uploaderhash=?", token
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
.small-7.medium-7.columns.packagepage
|
||||
p.subtitle = @package.description
|
||||
- if @package.screenshots_visible_to_user.count > 0
|
||||
- @package.screenshots_visible_to_user.each do |screenshot|
|
||||
- if @package.screenshots_visible_to_user(session[:token]).count > 0
|
||||
- @package.screenshots_visible_to_user(session[:token]).each do |screenshot|
|
||||
.row.listview
|
||||
.small-12.columns
|
||||
.text-center
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue