Creating query to get screenshots visible to a user

This commit is contained in:
Christoph Haas 2016-03-05 15:55:24 +01:00
parent 53b297da1e
commit 6192e1bc3b
3 changed files with 19 additions and 16 deletions

View file

@ -1,2 +1,13 @@
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