Update import news from Rss2, handle some exceptions

This commit is contained in:
Manson Wang 2014-03-20 17:32:44 +08:00
parent 1c385e831a
commit e8b273ee74
1 changed files with 9 additions and 1 deletions

View File

@ -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"]