Auto-approval and upload fixed
This commit is contained in:
parent
0dd63f6bf6
commit
1b299d53e6
5 changed files with 49 additions and 34 deletions
|
|
@ -50,24 +50,6 @@ class User < ApplicationRecord
|
|||
self.provider == nil
|
||||
end
|
||||
|
||||
# Do uploads from this user get approved automatically?
|
||||
def auto_approve?
|
||||
# Anonymous users need to go through moderation
|
||||
return false unless user_signed_in?
|
||||
|
||||
# Admins do not need moderation
|
||||
return true if current_user.is_admin?
|
||||
|
||||
# Debian developers do not need moderation
|
||||
return true if current_user.provider == 'debian-sso'
|
||||
|
||||
# After one successfully approved screenshot users do not need moderation
|
||||
return true if current_user.approved_screenshots.count > 0
|
||||
|
||||
# Any other user's upload must be moderated
|
||||
return false
|
||||
end
|
||||
|
||||
def self.from_omniauth(auth)
|
||||
where(provider: auth.provider, email: auth.info.email).first_or_create do |user|
|
||||
user.provider = auth.provider
|
||||
|
|
@ -79,6 +61,10 @@ class User < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def approved_screenshots
|
||||
self.screenshots.where(approved: true)
|
||||
end
|
||||
|
||||
# Seamlessly create a user account for the current client.
|
||||
# It helps track uploads because uploaded screenshots get assigned
|
||||
# to this user record. The user can later decide to use a real
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue