fix for xls import for blank url and files descriptions

This commit is contained in:
Harry Bomrah 2016-06-29 18:37:03 +08:00
parent ec4f25170d
commit b974cb771a
1 changed files with 8 additions and 8 deletions

View File

@ -87,9 +87,9 @@ module Admin::AnnouncementsHelper
anns.text_translations = value anns.text_translations = value
value = {} value = {}
when 16 when 16
links = val.split(";") links = val.split(";") rescue []
desc_en = row.cells[17].value.split(";") desc_en = row.cells[17].value.split(";") rescue []
desc_zh_tw = row.cells[18].value.split(";") desc_zh_tw = row.cells[18].value.split(";") rescue []
links.each_with_index do |link,i| links.each_with_index do |link,i|
bl = BulletinLink.new bl = BulletinLink.new
bl.url = link.strip bl.url = link.strip
@ -98,11 +98,11 @@ module Admin::AnnouncementsHelper
bl.save bl.save
end end
when 19 when 19
files = val.split(";") files = val.split(";") rescue []
desc_en = row.cells[20].value.split(";") desc_en = row.cells[20].value.split(";") rescue []
desc_zh_tw = row.cells[21].value.split(";") desc_zh_tw = row.cells[21].value.split(";") rescue []
alt_en = row.cells[22].value.split(";") alt_en = row.cells[22].value.split(";") rescue []
alt_zh_tw = row.cells[23].value.split(";") alt_zh_tw = row.cells[23].value.split(";") rescue []
files.each_with_index do |file, i| files.each_with_index do |file, i|
bf = BulletinFile.new bf = BulletinFile.new
bf.remote_file_url = file.strip rescue nil bf.remote_file_url = file.strip rescue nil