Don't show the link to "Needs Approval" unless approval is enabled.

Note that any plugin that extends the NewPostMananger to support
enqueuing will enable it.
This commit is contained in:
Robin Ward 2015-04-21 13:59:57 -04:00
parent dd3953bf19
commit 26693c16ac
4 changed files with 27 additions and 3 deletions

View File

@ -30,12 +30,12 @@
<li>{{#link-to 'users'}}{{i18n "directory.title"}}{{/link-to}}</li> <li>{{#link-to 'users'}}{{i18n "directory.title"}}{{/link-to}}</li>
{{/if}} {{/if}}
{{#if currentUser.staff}} {{#if currentUser.show_queued_posts}}
<li> <li>
{{#link-to 'queued-posts'}} {{#link-to 'queued-posts'}}
{{i18n "queue.title"}} {{i18n "queue.title"}}
{{#if currentUser.post_queue_new_count}} {{#if currentUser.post_queue_new_count}}
<span class='badge-notification flagged-posts'>{{currentUser.post_queue_new_count}}</span> <span class='badge-notification flagged-posts'>{{currentUser.post_queue_new_count}}</span>
{{/if}} {{/if}}
{{/link-to}} {{/link-to}}
</li> </li>

View File

@ -1,3 +1,5 @@
require_dependency 'new_post_manager'
class CurrentUserSerializer < BasicUserSerializer class CurrentUserSerializer < BasicUserSerializer
attributes :name, attributes :name,
@ -27,7 +29,8 @@ class CurrentUserSerializer < BasicUserSerializer
:muted_category_ids, :muted_category_ids,
:dismissed_banner_key, :dismissed_banner_key,
:is_anonymous, :is_anonymous,
:post_queue_new_count :post_queue_new_count,
:show_queued_posts
def include_site_flagged_posts_count? def include_site_flagged_posts_count?
object.staff? object.staff?
@ -116,4 +119,12 @@ class CurrentUserSerializer < BasicUserSerializer
object.staff? object.staff?
end end
def show_queued_posts
true
end
def include_show_queued_posts?
object.staff? && NewPostManager.queue_enabled?
end
end end

View File

@ -26,6 +26,12 @@ class NewPostManager
end end
end end
def self.queue_enabled?
SiteSetting.approve_post_count > 0 ||
SiteSetting.approve_unless_trust_level.to_i > 0 ||
handlers.size > 1
end
add_handler {|manager| default_handler(manager) } add_handler {|manager| default_handler(manager) }
def initialize(user, args) def initialize(user, args)

View File

@ -28,6 +28,7 @@ describe NewPostManager do
it "doesn't return a result action" do it "doesn't return a result action" do
result = NewPostManager.default_handler(manager) result = NewPostManager.default_handler(manager)
expect(NewPostManager.queue_enabled?).to eq(false)
expect(result).to eq(nil) expect(result).to eq(nil)
end end
end end
@ -38,6 +39,7 @@ describe NewPostManager do
end end
it "will return an enqueue result" do it "will return an enqueue result" do
result = NewPostManager.default_handler(manager) result = NewPostManager.default_handler(manager)
expect(NewPostManager.queue_enabled?).to eq(true)
expect(result.action).to eq(:enqueued) expect(result.action).to eq(:enqueued)
end end
end end
@ -48,6 +50,7 @@ describe NewPostManager do
end end
it "will return an enqueue result" do it "will return an enqueue result" do
result = NewPostManager.default_handler(manager) result = NewPostManager.default_handler(manager)
expect(NewPostManager.queue_enabled?).to eq(true)
expect(result.action).to eq(:enqueued) expect(result.action).to eq(:enqueued)
end end
end end
@ -79,6 +82,10 @@ describe NewPostManager do
NewPostManager.handlers.delete(@queue_handler) NewPostManager.handlers.delete(@queue_handler)
end end
it "has a queue enabled" do
expect(NewPostManager.queue_enabled?).to eq(true)
end
it "calls custom handlers" do it "calls custom handlers" do
manager = NewPostManager.new(topic.user, raw: 'this post increases counter', topic_id: topic.id) manager = NewPostManager.new(topic.user, raw: 'this post increases counter', topic_id: topic.id)