personal-journal/app/controllers/desktop/journal_papers_controller.rb

43 lines
1012 B
Ruby
Raw Normal View History

2014-11-18 11:03:18 +00:00
class Desktop::JournalPapersController < DesktopAdminController
2014-11-18 12:55:07 +00:00
def menu
2014-11-21 06:13:38 +00:00
user = OrbitHelper.current_user
2014-11-18 12:55:07 +00:00
[
{
"title" => "List",
"layout" => "list",
2014-11-19 10:26:33 +00:00
"data" => get_paper_list
2014-11-18 12:55:07 +00:00
},
{
"title" => "Add/Edit",
"layout" => "form",
2014-11-21 06:13:38 +00:00
"new_path" => "/admin/members/#{user.member_profile.to_param}/journal_papers/new"
}
2014-11-18 12:55:07 +00:00
]
2014-11-18 11:03:18 +00:00
end
2014-11-19 10:26:33 +00:00
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
{
2014-11-19 11:55:24 +00:00
"id" => j.id.to_s,
2014-11-19 10:26:33 +00:00
"paper_title" => j.paper_title,
"journal_title" => j.journal_title,
"keywords" => j.keywords,
"abstract" => j.abstract,
"files" => files
}
end
journals
end
2014-11-18 11:03:18 +00:00
end