From 9aba666d3ff3d64c90a44a4e6d7d60b2a995d01f Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 28 May 2014 13:33:39 -0400 Subject: [PATCH] Also warn admins when there aren't at least 50 posts --- app/assets/javascripts/discourse.js | 13 +++++++++---- app/serializers/basic_category_serializer.rb | 1 + config/locales/client.en.yml | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse.js b/app/assets/javascripts/discourse.js index 67265b7aad9..393c7bedc89 100644 --- a/app/assets/javascripts/discourse.js +++ b/app/assets/javascripts/discourse.js @@ -165,10 +165,15 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, { } if(Discourse.User.currentProp('admin') && Discourse.SiteSettings.show_create_topics_notice) { - var topic_count = _.reduce(Discourse.Site.currentProp('categories'), function(sum,c) { - return sum + (c.get('read_restricted') ? 0 : c.get('topic_count')); - }, 0); - if (topic_count < 5) { + var topic_count = 0, + post_count = 0; + _.each(Discourse.Site.currentProp('categories'), function(c) { + if (!c.get('read_restricted')) { + topic_count += c.get('topic_count'); + post_count += c.get('post_count'); + } + }); + if (topic_count < 5 || post_count < 50) { notices.push(I18n.t("too_few_topics_notice")); } } diff --git a/app/serializers/basic_category_serializer.rb b/app/serializers/basic_category_serializer.rb index f1b84ad6043..8fca40e980e 100644 --- a/app/serializers/basic_category_serializer.rb +++ b/app/serializers/basic_category_serializer.rb @@ -6,6 +6,7 @@ class BasicCategorySerializer < ApplicationSerializer :text_color, :slug, :topic_count, + :post_count, :description, :topic_url, :read_restricted, diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 7d697ff3039..ee30b34b528 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -446,7 +446,7 @@ en: read_only_mode: enabled: "An administrator has enabled read-only mode. You can continue to browse the site but interactions won't work properly." login_disabled: "Login is disabled while the site is in read only mode." - too_few_topics_notice: "Create at least 5 public topics to get discussion started. New users won't be able to earn trust levels unless there's content for them to read." + too_few_topics_notice: "Create at least 5 topics and 50 posts to get discussion started. New users will not be able to earn trust levels unless there's content for them to read." learn_more: "learn more..."