From e8b273ee74f775707c1dbfd846fc4569cc62abe7 Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Thu, 20 Mar 2014 17:32:44 +0800 Subject: [PATCH] Update import news from Rss2, handle some exceptions --- app/controllers/admin/import_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/import_controller.rb b/app/controllers/admin/import_controller.rb index 40696e9..1f69425 100644 --- a/app/controllers/admin/import_controller.rb +++ b/app/controllers/admin/import_controller.rb @@ -50,7 +50,14 @@ class Admin::ImportController < OrbitBackendController bulletin.title_translations = row['Title'] bulletin.subtitle_translations = row['Summary'] + next if row['Title']==[] and row['Summary']==[] and row['Content']==[] + @site_valid_locales.each do |locale| + if row['Content'][locale]=="" and row['Summary'][locale]!="" + row['Content'][locale] = row['Summary'][locale] + row['Summary'][locale] = " " + end + temp = row['Content'][locale] urls = Nokogiri::HTML(temp).css("img").map do |link| @@ -60,6 +67,7 @@ class Admin::ImportController < OrbitBackendController end urls.each do |url| + next if url.nil? a = Asset.new a.remote_data_url = url a.assetable_type = "User" @@ -73,7 +81,7 @@ class Admin::ImportController < OrbitBackendController bulletin.text_translations = row['Content'] bulletin.category_id = @new_category_ids[row["Category"]] - bulletin.view_count = row["Visits"] + bulletin.view_count = row["Visits"].blank? ? 0 : row["Visits"] bulletin.postdate = row["PostDate"] bulletin.deadline = row['Deadline'] bulletin.remote_image_url = row["Pic"] if row["Pic"]