Working on query to only display moderated or own uploads

This commit is contained in:
Christoph Haas 2016-03-04 18:23:12 +01:00
parent 5147497d3f
commit 53b297da1e

View file

@ -31,4 +31,22 @@ class Package < ActiveRecord::Base
subselect = Screenshot.select(:package_id)
where.not(id: subselect)
end
# Return a query of all approved/public screenshots of this package
def self.query_approved
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)
working on it
def self.query_visible_to_user
approved_screenshots = Screenshot.find_by()
subselect = Screenshot.select(:package_id)
where.not(id: subselect)
end
end