2014-07-03 07:48:28 +00:00
|
|
|
module Admin::BooksHelper
|
|
|
|
def page_for_book(book_object)
|
|
|
|
book_page = nil
|
|
|
|
page = Page.find_by(:module=>"book") rescue nil
|
|
|
|
|
|
|
|
book_page = page if book_page.nil?
|
|
|
|
request.protocol+(request.host_with_port+book_page.url+'/'+book_object.to_param).gsub('//','/') rescue "/"
|
|
|
|
end
|
2014-12-05 06:37:24 +00:00
|
|
|
|
|
|
|
def get_paper_list
|
|
|
|
user = current_user.nil? ? OrbitHelper.current_user : current_user
|
|
|
|
user_profile = user.member_profile
|
|
|
|
books = Book.where(:member_profile_id => user_profile.id)
|
|
|
|
books = books.collect do |b|
|
|
|
|
files = b.book_files.collect do |bf|
|
|
|
|
{
|
|
|
|
"title" => bf.title,
|
|
|
|
"description" => bf.description,
|
|
|
|
"link" => bf.member_book_file.url,
|
|
|
|
"extension" => (bf.file.url.split(".").last rescue "")
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"id" => b.id.to_s,
|
|
|
|
"edit_url" => "/#{I18n.locale.to_s}/admin/books/#{b.to_param}/edit",
|
|
|
|
"delete_url" => "/#{I18n.locale.to_s}/admin/books/#{b.id.to_s}",
|
|
|
|
"paper_title" => b.book_title,
|
|
|
|
"keywords" => b.keywords,
|
|
|
|
"files" => files
|
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
books
|
|
|
|
end
|
2014-07-03 07:48:28 +00:00
|
|
|
end
|