Update import news from Rss2, handle some exceptions
This commit is contained in:
parent
1c385e831a
commit
e8b273ee74
|
@ -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"]
|
||||
|
|
Loading…
Reference in New Issue