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