module Admin::PersonalDiplomasHelper def get_paper_list user = current_user.nil? ? OrbitHelper.current_user : current_user user_profile = user.member_profile diplomas = Diploma.where(:member_profile_id => user_profile.id) diplomas = diplomas.collect do |d| { "id" => d.id.to_s, "edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/diplomas/#{d.to_param}/edit", "delete_url" => "/#{I18n.locale.to_s}/admin/diplomas/#{d.id.to_s}", "paper_title" => d.school_name, "files" => [] } end diplomas end def import_this_diploma(row, mp) value = nil diploma = Diploma.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 diploma.school_name_translations = value when 4 value = {"en" => val} when 5 begin value["zh_tw"] = val rescue value = {"zh_tw" => val} end diploma.country_translations = value when 6 value = {"en" => val} when 7 begin value["zh_tw"] = val rescue value = {"zh_tw" => val} end diploma.department_translations = value when 8 value = {"en" => val} when 9 begin value["zh_tw"] = val rescue value = {"zh_tw" => val} end diploma.degree_translations = value when 10 diploma.start_date = val when 11 diploma.end_date = val when 12 diploma.language =val when 13 diploma.url = val when 14 diploma.keywords = val when 15 diploma.note = val end end diploma.member_profile = mp diploma.save end end