From 56d26261878bce60c0b1cd2c70596b0195984a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 27 Jul 2016 18:38:23 +0200 Subject: [PATCH] support 'read_restricted' categories in importers --- script/import_scripts/base.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script/import_scripts/base.rb b/script/import_scripts/base.rb index f0968c212..5f8c38170 100644 --- a/script/import_scripts/base.rb +++ b/script/import_scripts/base.rb @@ -389,12 +389,13 @@ class ImportScripts::Base new_category = Category.new( name: opts[:name], - user_id: opts[:user_id] || opts[:user].try(:id) || -1, + user_id: opts[:user_id] || opts[:user].try(:id) || Discourse::SYSTEM_USER_ID, position: opts[:position], description: opts[:description], parent_category_id: opts[:parent_category_id], color: opts[:color] || "AB9364", text_color: opts[:text_color] || "FFF", + read_restricted: opts[:read_restricted] || false, ) new_category.custom_fields["import_id"] = import_id if import_id @@ -466,7 +467,7 @@ class ImportScripts::Base [created, skipped] end - STAFF_GUARDIAN = Guardian.new(User.find(-1)) + STAFF_GUARDIAN ||= Guardian.new(Discourse.system_user) def create_post(opts, import_id) user = User.find(opts[:user_id])