From f38655a9d9a7918602753e8b0e1ea2eba450a145 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 19 Nov 2014 18:26:33 +0800 Subject: [PATCH] list for journal papers --- .../desktop/journal_papers_controller.rb | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app/controllers/desktop/journal_papers_controller.rb b/app/controllers/desktop/journal_papers_controller.rb index 64ae81d..b37a055 100644 --- a/app/controllers/desktop/journal_papers_controller.rb +++ b/app/controllers/desktop/journal_papers_controller.rb @@ -4,7 +4,7 @@ class Desktop::JournalPapersController < DesktopAdminController { "title" => "List", "layout" => "list", - "data" => [] + "data" => get_paper_list }, { "title" => "Add/Edit", @@ -13,4 +13,29 @@ class Desktop::JournalPapersController < DesktopAdminController } ] end + + def get_paper_list + user = OrbitHelper.current_user + user_profile = user.member_profile + journals = JournalPaper.where(:member_profile_id => user_profile.id) + journals = journals.collect do |j| + files = j.journal_paper_files.collect do |jpf| + { + "title" => jpf.title, + "description" => jpf.description, + "link" => jpf.journal_file.url, + "extension" => (jpf.journal_file.url.split(".").last rescue "") + } + end + { + "paper_title" => j.paper_title, + "journal_title" => j.journal_title, + "keywords" => j.keywords, + "abstract" => j.abstract, + "files" => files + } + end + journals + end + end \ No newline at end of file