module Admin::PersonalProjectsHelper def get_paper_list user = current_user.nil? ? OrbitHelper.current_user : current_user user_profile = user.member_profile projects = Project.where(:member_profile_id => user_profile.id) projects = projects.collect do |p| files = p.project_files.collect do |pf| { "title" => pf.title, "description" => pf.description, "link" => pf.file.url, "extension" => (pf.file.url.split(".").last rescue "") } end { "id" => p.id.to_s, "edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/projects/#{p.to_param}/edit", "delete_url" => "/#{I18n.locale.to_s}/admin/projects/#{p.id.to_s}", "paper_title" => p.project_title, "keywords" => p.keywords, "abstract" => p.abstract, "files" => files } end projects end def import_this_project(row, mp) value = nil project = Project.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 project.project_title_translations = value when 4 value = {"en" => val} when 5 begin value["zh_tw"] = val rescue value = {"zh_tw" => val} end project.job_title_translations = value when 6 value = {"en" => val} when 7 begin value["zh_tw"] = val rescue value = {"zh_tw" => val} end project.participator_translations = value when 8 value = {"en" => val} when 9 begin value["zh_tw"] = val rescue value = {"zh_tw" => val} end project.unit_translations = value when 10 project.year = val when 11 project.language = val when 12 pts = ProjectType.asc(:created_at).all.to_a project.project_type = pts[val.to_i] if val.to_s.is_i? && val.to_i < pts.count when 13 project.period_start_date = val when 14 project.period_end_date = val when 15 project.url = val when 16 project.keywords = val when 17 project.abstract = val when 18 project.note = val end end project.member_profile = mp project.save end end