Dammit… I can't remember what I changed and why

This commit is contained in:
Christoph Haas 2018-05-06 19:07:41 +02:00
parent 09b0df40f7
commit dd7527691e
20 changed files with 579 additions and 319 deletions

View file

@ -3,16 +3,16 @@ 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)
# - all screenshots if the user is logged in
# - screenshots uploaded by the user
# - all screenshots if the user is an admin
def screenshots_visible_to_user(package)
if user_signed_in?
if user_signed_in? and current_user.is_admin?
# User is an admin
package.screenshots.order('created_at DESC')
package.screenshots
elsif user_signed_in?
current_user.screenshots
else
package.screenshots.where(
"approved=true OR uploaderhash=?", session[:token]
).order('created_at DESC')
package.screenshots.where(approved: true).order('created_at DESC')
end
end