Show a warning to admins if the site has fewer than 5 topics.

This commit is contained in:
Neil Lalonde 2014-05-23 12:25:16 -04:00
parent 8267a451b2
commit 512771932a
3 changed files with 15 additions and 0 deletions

View file

@ -164,6 +164,15 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
notices.push(I18n.t("read_only_mode.enabled")); notices.push(I18n.t("read_only_mode.enabled"));
} }
if(Discourse.User.currentProp('admin')) {
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) {
notices.push(I18n.t("too_few_topics_notice"));
}
}
if(!_.isEmpty(Discourse.SiteSettings.global_notice)){ if(!_.isEmpty(Discourse.SiteSettings.global_notice)){
notices.push(Discourse.SiteSettings.global_notice); notices.push(Discourse.SiteSettings.global_notice);
} }

View file

@ -498,6 +498,11 @@ Discourse.Composer = Discourse.Model.extend({
// We created a new topic, let's show it. // We created a new topic, let's show it.
composer.set('composeState', CLOSED); composer.set('composeState', CLOSED);
saving = false; saving = false;
// Update topic_count for the category
var category = Discourse.Site.currentProp('categories').find(function(x) { return x.get('id') === (parseInt(createdPost.get('category'),10) || 1); });
if (category) category.incrementProperty('topic_count');
Discourse.notifyPropertyChange('globalNotice');
} }
composer.clearState(); composer.clearState();

View file

@ -442,6 +442,7 @@ en:
read_only_mode: read_only_mode:
enabled: "An administrator has enabled read-only mode. You can continue to browse the site but interactions won't work properly." 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." login_disabled: "Login is disabled while the site is in read only mode."
too_few_topics_notice: "Create at least 5 topics 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..." learn_more: "learn more..."