From eceeef8413d3579c403153af88d84b4d58cfa264 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Tue, 22 May 2018 21:27:25 +0200 Subject: [PATCH] Imported categories use colors from settings instead of brown --- script/import_scripts/base.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/script/import_scripts/base.rb b/script/import_scripts/base.rb index 03a62dcc22a..c8d41e29320 100644 --- a/script/import_scripts/base.rb +++ b/script/import_scripts/base.rb @@ -442,7 +442,7 @@ class ImportScripts::Base user_id: opts[:user_id] || opts[:user].try(:id) || Discourse::SYSTEM_USER_ID, position: opts[:position], parent_category_id: opts[:parent_category_id], - color: opts[:color] || "AB9364", + color: opts[:color] || category_color, text_color: opts[:text_color] || "FFF", read_restricted: opts[:read_restricted] || false, ) @@ -463,6 +463,15 @@ class ImportScripts::Base new_category end + def category_color + @category_colors ||= SiteSetting.category_colors.split('|') + + index = @next_category_color_index.presence || 0 + @next_category_color_index = index + 1 >= @category_colors.count ? 0 : index + 1 + + @category_colors[index] + end + def created_post(post) # override if needed end