Fix import bug.

This commit is contained in:
BoHung Chiu 2021-07-16 16:26:28 +08:00
parent dc9c36711d
commit d0bb7ee9e7
1 changed files with 5 additions and 1 deletions

View File

@ -33,7 +33,7 @@ module Admin::AnnouncementsHelper
value = {} value = {}
anns = Bulletin.new anns = Bulletin.new
row.cells.each_with_index do |cell,index| row.cells.each_with_index do |cell,index|
val = cell.value rescue nil val = cell.nil? ? nil : cell.value rescue nil
if [8,9,10,11,12,13,14,15].exclude?(index) if [8,9,10,11,12,13,14,15].exclude?(index)
next if val.blank? next if val.blank?
end end
@ -65,24 +65,28 @@ module Admin::AnnouncementsHelper
anns.remote_image_url = val anns.remote_image_url = val
when 8 when 8
value["en"] = val value["en"] = val
anns.image_description_translations = value
when 9 when 9
value["zh_tw"] = val value["zh_tw"] = val
anns.image_description_translations = value anns.image_description_translations = value
value = {} value = {}
when 10 when 10
value["en"] = val value["en"] = val
anns.title_translations = value
when 11 when 11
value["zh_tw"] = val value["zh_tw"] = val
anns.title_translations = value anns.title_translations = value
value = {} value = {}
when 12 when 12
value["en"] = val value["en"] = val
anns.subtitle_translations = value
when 13 when 13
value["zh_tw"] = val value["zh_tw"] = val
anns.subtitle_translations = value anns.subtitle_translations = value
value = {} value = {}
when 14 when 14
value["en"] = val value["en"] = val
anns.text_translations = value
when 15 when 15
value["zh_tw"] = val value["zh_tw"] = val
anns.text_translations = value anns.text_translations = value