From eaafbccb53c2bd647ce167c58fe03f419ebb3082 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Tue, 29 Jul 2014 14:30:23 -0400 Subject: [PATCH] Seed the Admin Quick Start Guide topic last so it appears as the newest topic --- db/fixtures/999_topics.rb | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/db/fixtures/999_topics.rb b/db/fixtures/999_topics.rb index 543f52f505f..2a38a2f18ba 100644 --- a/db/fixtures/999_topics.rb +++ b/db/fixtures/999_topics.rb @@ -3,24 +3,7 @@ Topic.reset_column_information Post.reset_column_information staff = Category.find_by(id: SiteSetting.staff_category_id) - -if Topic.where('id NOT IN (SELECT topic_id from categories where topic_id is not null)').count == 0 && !Rails.env.test? - puts "Seeding welcome topics" - - welcome = File.read(Rails.root + 'docs/ADMIN-QUICK-START-GUIDE.md') - PostCreator.create(Discourse.system_user, raw: welcome, title: "READ ME FIRST: Admin Quick Start Guide", skip_validations: true, category: staff ? staff.name : nil) - PostCreator.create(Discourse.system_user, raw: I18n.t('assets_topic_body'), title: "Assets for the forum design", skip_validations: true, category: staff ? staff.name : nil) - - welcome = File.read(Rails.root + 'docs/WELCOME-TO-DISCOURSE.md') - post = PostCreator.create(Discourse.system_user, raw: welcome, title: "Welcome to Discourse", skip_validations: true) - post.topic.update_pinned(true, true) - - lounge = Category.find_by(id: SiteSetting.lounge_category_id) - if lounge - post = PostCreator.create(Discourse.system_user, raw: I18n.t('lounge_welcome.body'), title: I18n.t('lounge_welcome.title'), skip_validations: true, category: lounge.name) - post.topic.update_pinned(true) - end -end +seed_welcome_topics = (Topic.where('id NOT IN (SELECT topic_id from categories where topic_id is not null)').count == 0 && !Rails.env.test?) unless Rails.env.test? def create_static_page_topic(site_setting_key, title_key, body_key, body_override, category, description, params={}) @@ -55,3 +38,22 @@ unless Rails.env.test? create_static_page_topic('privacy_topic_id', 'privacy_topic.title', "privacy_topic.body", (SiteContent.content_for(:privacy_policy) rescue nil), staff, "privacy policy") end + +if seed_welcome_topics + puts "Seeding welcome topics" + + PostCreator.create(Discourse.system_user, raw: I18n.t('assets_topic_body'), title: "Assets for the forum design", skip_validations: true, category: staff ? staff.name : nil) + + welcome = File.read(Rails.root + 'docs/WELCOME-TO-DISCOURSE.md') + post = PostCreator.create(Discourse.system_user, raw: welcome, title: "Welcome to Discourse", skip_validations: true) + post.topic.update_pinned(true, true) + + lounge = Category.find_by(id: SiteSetting.lounge_category_id) + if lounge + post = PostCreator.create(Discourse.system_user, raw: I18n.t('lounge_welcome.body'), title: I18n.t('lounge_welcome.title'), skip_validations: true, category: lounge.name) + post.topic.update_pinned(true) + end + + welcome = File.read(Rails.root + 'docs/ADMIN-QUICK-START-GUIDE.md') + PostCreator.create(Discourse.system_user, raw: welcome, title: "READ ME FIRST: Admin Quick Start Guide", skip_validations: true, category: staff ? staff.name : nil) +end