personal-patent/app/helpers/admin/personal_patents_helper.rb

28 lines
900 B
Ruby
Raw Normal View History

2014-12-04 07:41:18 +00:00
module Admin::PersonalPatentsHelper
def get_paper_list
user = current_user.nil? ? OrbitHelper.current_user : current_user
user_profile = user.member_profile
patents = Patent.where(:member_profile_id => user_profile.id)
patents = patents.collect do |p|
files = p.patent_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}/patents/#{p.to_param}/edit",
"delete_url" => "/#{I18n.locale.to_s}/admin/patents/#{p.id.to_s}",
"paper_title" => p.patent_title,
"keywords" => p.keywords,
"abstract" => [],
"files" => files
}
end
patents
end
end