Updated Data import and sync code
This commit is contained in:
parent
f2a27c6b40
commit
b535f2cf9c
|
@ -41,13 +41,19 @@ class Admin::ImportDataController < OrbitBackendController
|
||||||
|
|
||||||
#@teacher.first_name = hash['teacher_en']
|
#@teacher.first_name = hash['teacher_en']
|
||||||
@teacher.ntu_seq = hash['ntu_seq']
|
@teacher.ntu_seq = hash['ntu_seq']
|
||||||
|
@teacher.sid = hash['ntu_seq']
|
||||||
@teacher.role_ids = ["#{@roles.skip(1).first.id}"]
|
@teacher.role_ids = ["#{@roles.skip(1).first.id}"]
|
||||||
@teacher.password = "testpass"
|
@teacher.password = "testpass"
|
||||||
@i += 10
|
@i += 10
|
||||||
if hash['email'].blank?
|
if !hash['email'].blank?
|
||||||
@teacher.email = "#{@i}@ntu.edu.tw"
|
@user = User.where(email: "#{hash['email']}")
|
||||||
|
if @user.length == 0
|
||||||
|
@teacher.email = hash['email']
|
||||||
|
elsif @user.length > 0
|
||||||
|
@teacher.email = "#{@i}duplicate@ntu.edu.tw"
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@teacher.email = hash['email']
|
@teacher.email = "#{@i}@ntu.edu.tw"
|
||||||
end
|
end
|
||||||
|
|
||||||
if hash['teacher_zh_tw'].blank? && hash['teacher_en'].blank?
|
if hash['teacher_zh_tw'].blank? && hash['teacher_en'].blank?
|
||||||
|
@ -211,7 +217,7 @@ class Admin::ImportDataController < OrbitBackendController
|
||||||
if b[:title].blank?
|
if b[:title].blank?
|
||||||
@journal_paper.paper_title = "No Title Present"
|
@journal_paper.paper_title = "No Title Present"
|
||||||
else
|
else
|
||||||
@journal_paper.paper_title = b[:title].first
|
@journal_paper.paper_title = b[:title]
|
||||||
end
|
end
|
||||||
@journal_paper.note = b[:remarks]
|
@journal_paper.note = b[:remarks]
|
||||||
@journal_paper.year = b[:year]
|
@journal_paper.year = b[:year]
|
||||||
|
|
Loading…
Reference in New Issue