personal-lab/app/helpers/admin/personal_labs_helper.rb

27 lines
886 B
Ruby
Raw Normal View History

2014-12-05 07:03:30 +00:00
module Admin::PersonalLabsHelper
def get_paper_list
user = current_user.nil? ? OrbitHelper.current_user : current_user
user_profile = user.member_profile
labs = Lab.where(:member_profile_id => user_profile.id)
labs = labs.collect do |l|
files = l.lab_files.collect do |lf|
{
"title" => lf.title,
"description" => lf.description,
"link" => lf.file.url,
"extension" => (lf.file.url.split(".").last rescue "")
}
end
{
"id" => l.id.to_s,
"edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/labs/#{l.to_param}/edit",
"delete_url" => "/#{I18n.locale.to_s}/admin/labs/#{l.id.to_s}",
"paper_title" => l.lab_title,
"keywords" => l.keywords,
"files" => files
}
end
labs
end
end