personal-experience/app/helpers/admin/personal_experiences_helper.rb

77 lines
1.9 KiB
Ruby
Raw Normal View History

2014-12-05 09:29:28 +00:00
module Admin::PersonalExperiencesHelper
def get_paper_list
user = current_user.nil? ? OrbitHelper.current_user : current_user
user_profile = user.member_profile
experiences = Experience.where(:member_profile_id => user_profile.id)
experiences = experiences.collect do |e|
{
"id" => e.id.to_s,
"edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/experiences/#{e.to_param}/edit",
"delete_url" => "/#{I18n.locale.to_s}/admin/experiences/#{e.id.to_s}",
"paper_title" => e.organizationt_title,
"keywords" => e.keywords,
"abstract" => [],
"files" => []
}
end
experiences
end
2015-12-14 08:13:25 +00:00
def import_this_experience(row,mp)
value = nil
exp = Experience.new
row.cells.each_with_index do |cell,index|
next if index < 2
next if cell.nil?
val = cell.value
next if val.nil? || val == ""
case index
when 2
value = {"en" => val}
when 3
begin
value["zh_tw"] = val
rescue
value = {"zh_tw" => val}
end
exp.organizationt_title_translations = value
when 4
value = {"en" => val}
when 5
begin
value["zh_tw"] = val
rescue
value = {"zh_tw" => val}
end
exp.department_translations = value
when 6
value = {"en" => val}
when 7
begin
value["zh_tw"] = val
rescue
value = {"zh_tw" => val}
end
exp.job_title_translations = value
when 8
ets = ExperienceType.asc(:created_at).all.to_a
exp.experience_type = ets[val.to_i] if val.to_s.is_i? && val.to_i < ets.count
when 9
exp.language = val
when 10
exp.start_date = val
when 11
exp.end_date = val
when 12
exp.url = val
when 13
exp.keywords = val
when 14
exp.note = val
end
end
exp.member_profile = mp
exp.save
end
2014-12-05 09:29:28 +00:00
end