Better docstrings
This commit is contained in:
parent
adb76650da
commit
8021c81d53
1 changed files with 11 additions and 11 deletions
|
|
@ -88,7 +88,7 @@ class Screenshot < ApplicationRecord
|
|||
return text
|
||||
end
|
||||
|
||||
# Short status text for admins
|
||||
# Brief text describing the status of this screenshots (for admins)
|
||||
def adminstatus
|
||||
if self.markedfordelete
|
||||
"Removal requested > #{self.delete_reason}"
|
||||
|
|
@ -107,37 +107,35 @@ class Screenshot < ApplicationRecord
|
|||
self.save!
|
||||
end
|
||||
|
||||
# Get the newest screenshot regardless of the package it belongs to
|
||||
def self.newest_upload
|
||||
self.order(updated_at: :desc).where(approved: true).first
|
||||
end
|
||||
|
||||
# def self.approved
|
||||
# self.find_by(approved: true)
|
||||
# end
|
||||
|
||||
# Check whether the user has administrative permissions
|
||||
# Returns true if the current user has administrative permissions
|
||||
def can_admin?
|
||||
self.admin == 1
|
||||
end
|
||||
|
||||
# Check whether an upload would require moderation
|
||||
# Returns true if the current user can upload screenshots without moderation
|
||||
def can_upload_without_moderation?
|
||||
# Admins can
|
||||
# Admins can upload without moderation
|
||||
true if self.can_admin
|
||||
|
||||
# Authenticated users with at least one approved screenshot
|
||||
true if self.screenshots.where(approved: true).count >= 1
|
||||
#true if self.screenshots.where(approved: true).count >= 1
|
||||
|
||||
# Other visitors require moderation
|
||||
false
|
||||
end
|
||||
|
||||
# Returns true if the current user can delete screenshots
|
||||
def can_delete?
|
||||
# Admins can
|
||||
# Admins can delete screenshots
|
||||
true if self.can_admin
|
||||
|
||||
# Authenticated users with at least one approved screenshot
|
||||
true if self.screenshots.where(approved: true).count >= 1
|
||||
#true if self.screenshots.where(approved: true).count >= 1
|
||||
|
||||
# Other visitors require moderation
|
||||
false
|
||||
|
|
@ -153,6 +151,7 @@ class Screenshot < ApplicationRecord
|
|||
ActiveStorage::Blob.service.send(:path_for, self.image.key)
|
||||
end
|
||||
|
||||
# Returns the MD5 hex digest of the current screenshot's data
|
||||
def checksum
|
||||
# local files stored on disk:
|
||||
# url = "#{Rails.root}/public/#{attachment.path}"
|
||||
|
|
@ -163,6 +162,7 @@ class Screenshot < ApplicationRecord
|
|||
#Digest::MD5.base64digest(Net::HTTP.get(URI(url)))
|
||||
end
|
||||
|
||||
# Returns the URL that links to a full-size screenshot image with a watermark
|
||||
def large_watermarked
|
||||
if self.image.attached?
|
||||
self.image.variant(combine_options: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue