Extract the `needs_approval?` logic

This commit is contained in:
Robin Ward 2015-04-28 16:14:36 -04:00
parent c2f7676370
commit 647dd76ba1
1 changed files with 6 additions and 4 deletions

View File

@ -28,11 +28,13 @@ class NewPostManager
@sorted_handlers.sort_by! {|h| -h[:priority]}
end
def self.user_needs_approval?(user)
(user.post_count < SiteSetting.approve_post_count) ||
(user.trust_level < SiteSetting.approve_unless_trust_level.to_i)
end
def self.default_handler(manager)
if (manager.user.post_count < SiteSetting.approve_post_count) ||
(manager.user.trust_level < SiteSetting.approve_unless_trust_level.to_i)
return manager.enqueue('default')
end
manager.enqueue('default') if user_needs_approval(manager.user)
end
def self.queue_enabled?