Added screenshots_visible_to_user helper
This commit is contained in:
parent
0aa959be84
commit
dd4d105b87
1 changed files with 17 additions and 0 deletions
|
|
@ -19,6 +19,23 @@ module PackagesHelper
|
|||
# end
|
||||
# end
|
||||
|
||||
def screenshots_visible_to_user(package, user_session)
|
||||
# Show all screenshots to admins
|
||||
if current_user && current_user.is_admin?
|
||||
package.screenshots
|
||||
|
||||
# Show screenshots belonging to the user or public/approved
|
||||
else
|
||||
package.screenshots.where(
|
||||
uploaderhash: user_session.id.to_s
|
||||
).or(
|
||||
package.screenshots.where(
|
||||
approved: true
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def screenshot_uploaded_by_current_user?(screenshot)
|
||||
screenshot.uploaderhash == session.id.to_s
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue