Authorisation management using CanCanCan added
This commit is contained in:
parent
51be4a4777
commit
7a3b65fe50
24 changed files with 211 additions and 295 deletions
|
|
@ -10,11 +10,6 @@ class Screenshot < ApplicationRecord
|
|||
# Shrine
|
||||
include ImageUploader::Attachment(:simage) # adds an `simage` virtual attribute
|
||||
|
||||
# Calculate how many days ago this screenshot has been uploaded
|
||||
def age
|
||||
time_ago_in_words(self.created_at)
|
||||
end
|
||||
|
||||
# Return caption for full-screen screenshots.
|
||||
# Takes the description of a screenshot if available.
|
||||
# Otherwise it falls back to the general description of its package.
|
||||
|
|
@ -54,19 +49,16 @@ class Screenshot < ApplicationRecord
|
|||
|
||||
# Brief text describing the status of this screenshots (for admins)
|
||||
def adminstatus
|
||||
if self.markedfordelete
|
||||
"Removal requested > #{self.delete_reason}"
|
||||
elsif self.approved
|
||||
if self.approved
|
||||
'Public'
|
||||
else
|
||||
fa_icon('hourglass') + 'Waiting for approval'
|
||||
#fa_icon('hourglass') + 'Waiting for approval'
|
||||
'Waiting for approval'
|
||||
end
|
||||
end
|
||||
|
||||
# Publish a screenshot from the moderation queue
|
||||
def approve!
|
||||
self.delete_reason = nil
|
||||
self.markedfordelete = false
|
||||
self.approved = true
|
||||
self.save!
|
||||
end
|
||||
|
|
@ -76,35 +68,6 @@ class Screenshot < ApplicationRecord
|
|||
self.order(created_at: :desc).where(approved: true).first
|
||||
end
|
||||
|
||||
# Returns true if the current user has administrative permissions
|
||||
# def can_admin?
|
||||
# self.admin == 1
|
||||
# end
|
||||
|
||||
# Returns true if the current user can upload screenshots without moderation
|
||||
# def can_upload_without_moderation?
|
||||
# # 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
|
||||
|
||||
# # Other visitors require moderation
|
||||
# false
|
||||
# end
|
||||
|
||||
# Returns true if the current user can delete screenshots
|
||||
# def can_delete?
|
||||
# # 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
|
||||
|
||||
# # Other visitors require moderation
|
||||
# false
|
||||
# end
|
||||
|
||||
# Return the part of the version up to the first - or +
|
||||
def upstream_version
|
||||
self.version.split(/[\-\+]/).first
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue