forked from saurabh/personal-lab
27 lines
886 B
Ruby
27 lines
886 B
Ruby
|
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
|