Updated import data controller to check the absense of title data

This commit is contained in:
saurabhbhatia 2013-09-11 11:37:42 +08:00
parent e4514a353a
commit 2a9948868f
1 changed files with 10 additions and 10 deletions

View File

@ -14,25 +14,25 @@ class Admin::ImportDataController < OrbitBackendController
@teacher_data = Hash.from_xml(res.body) @teacher_data = Hash.from_xml(res.body)
@teachers = @teacher_data["objects"] @teachers = @teacher_data["objects"]
@i = 2000 @i = 5000
@teachers.each do |hash| @teachers.each do |hash|
@roles = Role.all @roles = Role.all
@teacher = User.new @teacher = User.new
I18n.locale = :zh_tw I18n.locale = :zh_tw
if hash['teacher_zh_tw'].blank? if hash['teacher_zh_tw'].blank? && hash['teacher_en'].blank?
@teacher.first_name = hash['teacher_en'] @teacher.first_name = "Please Fill the Name"
elsif hash['teacher_zh_tw'].blank? && hash['teacher_en'].blank? elsif hash['teacher_zh_tw'].blank? && !hash['teacher_en'].blank?
@teacher.first_name = "Please Fill the Name" @teacher.first_name = hash['teacher_en']
else else
@teacher.first_name = hash['teacher_zh_tw'] @teacher.first_name = hash['teacher_zh_tw']
end end
I18n.locale = :en I18n.locale = :en
if hash['teacher_en'].blank? if hash['teacher_zh_tw'].blank? && hash['teacher_en'].blank?
@teacher.first_name = "Please Fill the Name"
elsif hash['teacher_en'].blank? && !hash['teacher_zh_tw'].blank?
@teacher.first_name = hash['teacher_zh_tw'] @teacher.first_name = hash['teacher_zh_tw']
elsif hash['teacher_zh_tw'].blank? && hash['teacher_en'].blank?
@teacher.first_name = "Please Fill the Name"
else else
@teacher.first_name = hash['teacher_en'] @teacher.first_name = hash['teacher_en']
end end
#@teacher.first_name = hash['teacher_en'] #@teacher.first_name = hash['teacher_en']