From 07af79c85bf6dca18c861e97ab94178387137c82 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 6 Feb 2015 16:03:41 -0500 Subject: [PATCH] Ning import: users who have never posted are trust level 0 --- script/import_scripts/base.rb | 6 ++++++ script/import_scripts/ning.rb | 14 ++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/script/import_scripts/base.rb b/script/import_scripts/base.rb index 5d33eb2fd..6334fbfeb 100644 --- a/script/import_scripts/base.rb +++ b/script/import_scripts/base.rb @@ -561,6 +561,12 @@ class ImportScripts::Base end end + def update_tl0 + User.all.each do |user| + user.change_trust_level!(0) if Post.where(user_id: user.id).count == 0 + end + end + def html_for_upload(upload, display_filename) if FileHelper.is_image?(upload.url) embedded_image_html(upload) diff --git a/script/import_scripts/ning.rb b/script/import_scripts/ning.rb index 72953ee25..5d8115420 100644 --- a/script/import_scripts/ning.rb +++ b/script/import_scripts/ning.rb @@ -15,8 +15,9 @@ class ImportScripts::Ning < ImportScripts::Base @users_json = load_ning_json("ning-members-local.json") @discussions_json = load_ning_json("ning-discussions-local.json") + + # An example of a custom category from Ning: @blogs_json = load_ning_json("ning-blogs-local.json") - @pages_json = load_ning_json("ning-pages-local.json") #SiteSetting.max_image_size_kb = 3072 #SiteSetting.max_attachment_size_kb = 1024 @@ -35,9 +36,11 @@ class ImportScripts::Ning < ImportScripts::Base import_users import_categories import_discussions - import_blogs - import_pages + + import_blogs # Remove this and/or add more as necessary + suspend_users + update_tl0 puts "", "Done" end @@ -179,11 +182,6 @@ class ImportScripts::Ning < ImportScripts::Base import_topics(@blogs_json, "Blog") end - def import_pages - puts "", "Importing pages" - import_topics(@pages_json, "Pages") - end - def import_topics(topics_json, default_category=nil) topics = 0 posts = 0