Dropdown on details page allows image management for users and admins

This commit is contained in:
Christoph Haas 2016-04-07 17:01:00 +02:00
parent 263f6cd33f
commit 16999260ca
8 changed files with 75 additions and 35 deletions

View file

@ -1,2 +1,19 @@
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
def screenshots_visible_to_user(package)
if user_signed_in?
# User is an admin
package.screenshots
else
package.screenshots.where(
"approved=true OR uploaderhash=?", session[:token]
)
end
end
end