Allow hiding and un-hiding of screenshot by moderators
This commit is contained in:
parent
f31502c333
commit
5d0e4a520e
6 changed files with 62 additions and 10 deletions
|
|
@ -5,7 +5,7 @@ class Screenshot < ApplicationRecord
|
|||
# Default sorting:
|
||||
# - unapproved first (to see them at the top when moderating)
|
||||
# - otherwise show newest first
|
||||
default_scope { order(approved: :asc, created_at: :desc) }
|
||||
default_scope { order(approved: :asc, hidden: :asc, created_at: :desc) }
|
||||
|
||||
# Shrine
|
||||
include ImageUploader::Attachment(:simage) # adds an `simage` virtual attribute
|
||||
|
|
@ -63,6 +63,16 @@ class Screenshot < ApplicationRecord
|
|||
self.save!
|
||||
end
|
||||
|
||||
# Hide a screenshot from the public. Moderator level can do this.
|
||||
def hide!
|
||||
self.hidden = true
|
||||
self.save!
|
||||
end
|
||||
def unhide!
|
||||
self.hidden = false
|
||||
self.save!
|
||||
end
|
||||
|
||||
# Get the newest screenshots regardless of the package it belongs to
|
||||
def self.newest
|
||||
self.order(created_at: :desc)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue