Add the posts that need to be reviewed to the hamburger

This commit is contained in:
Robin Ward 2015-04-10 16:29:13 -04:00
parent 7f501a0c41
commit f1ede42569
8 changed files with 44 additions and 5 deletions

View File

@ -99,6 +99,7 @@ HeaderController.reopenClass({
});
addFlagProperty('currentUser.site_flagged_posts_count');
addFlagProperty('currentUser.post_queue_new_count');
export { addFlagProperty };
export default HeaderController;

View File

@ -27,10 +27,13 @@ export default {
bus.callbackInterval = siteSettings.polling_interval;
bus.enableLongPolling = true;
if (user.admin || user.moderator) {
bus.subscribe('/flagged_counts', function(data) {
if (user.get('staff')) {
bus.subscribe('/flagged_counts', (data) => {
user.set('site_flagged_posts_count', data.total);
});
bus.subscribe('/queue_counts', (data) => {
user.set('post_queue_new_count', data.post_queue_new_count);
});
}
bus.subscribe("/notification/" + user.get('id'), (function(data) {
const oldUnread = user.get('unread_notifications');

View File

@ -26,6 +26,17 @@
<li>{{#link-to 'users'}}{{i18n "directory.title"}}{{/link-to}}</li>
{{/if}}
{{#if currentUser.staff}}
<li>
<a href="/queued-posts">
{{i18n "queue.title"}}
{{#if currentUser.post_queue_new_count}}
<span class='badge-notification flagged-posts'>{{currentUser.post_queue_new_count}}</span>
{{/if}}
</a>
</li>
{{/if}}
{{plugin-outlet "site-map-links"}}
{{#if showKeyboardShortcuts}}

View File

@ -26,6 +26,15 @@ class QueuedPost < ActiveRecord::Base
@states ||= Enum.new(:new, :approved, :rejected)
end
def self.new_count
where(state: states[:new]).count
end
def self.publish_new!
msg = { post_queue_new_count: QueuedPost.new_count }
MessageBus.publish('/queue_counts', msg, user_ids: User.staff.pluck(:id))
end
def reject!(rejected_by)
change_to!(:rejected, rejected_by)
end
@ -73,6 +82,8 @@ class QueuedPost < ActiveRecord::Base
# Update the record in memory too, and clear the dirty flag
updates.each {|k, v| send("#{k}=", v) }
changes_applied
QueuedPost.publish_new!
end
end

View File

@ -26,7 +26,8 @@ class CurrentUserSerializer < BasicUserSerializer
:custom_fields,
:muted_category_ids,
:dismissed_banner_key,
:is_anonymous
:is_anonymous,
:post_queue_new_count
def include_site_flagged_posts_count?
object.staff?
@ -107,4 +108,12 @@ class CurrentUserSerializer < BasicUserSerializer
object.anonymous?
end
def post_queue_new_count
QueuedPost.new_count
end
def include_post_queue_new_count?
object.staff?
end
end

View File

@ -226,6 +226,8 @@ en:
placeholder: "type the topic title here"
queue:
title: "Needs Approval"
approval:
title: "Post Needs Approval"
description: "We've received your new post but it needs to be approved by a moderator before it will appear. Please be patient."

View File

@ -43,6 +43,8 @@ class NewPostManager
enqueuer = PostEnqueuer.new(@user, queue)
post = enqueuer.enqueue(@args)
QueuedPost.publish_new! if post && post.errors.empty?
result.check_errors_from(enqueuer)
result
end

View File

@ -52,7 +52,7 @@ describe NewPostManager do
expect(result).to be_success
expect(result.post).to be_blank
expect(@counter).to be(1)
expect(QueuedPost.count).to be(0)
expect(QueuedPost.new_count).to be(0)
end
it "calls custom enqueuing handlers" do
@ -63,7 +63,7 @@ describe NewPostManager do
expect(result.action).to eq(:enqueued)
expect(result).to be_success
expect(result.post).to be_blank
expect(QueuedPost.count).to be(1)
expect(QueuedPost.new_count).to be(1)
expect(@counter).to be(0)
end