49 lines
1.3 KiB
Ruby
49 lines
1.3 KiB
Ruby
class Desktop::JournalPapersController < DesktopAdminController
|
|
def menu
|
|
user = OrbitHelper.current_user
|
|
[
|
|
{
|
|
"title" => "List",
|
|
"layout" => "list",
|
|
"data" => get_paper_list
|
|
},
|
|
{
|
|
"title" => "Add/Edit",
|
|
"layout" => "form",
|
|
"new_file_attributes" => {
|
|
"file" => "journal_paper[journal_paper_files_attributes][{number}][journal_file]",
|
|
"title" => "journal_paper[journal_paper_files_attributes][{number}][title_translations][{langugae}]"
|
|
},
|
|
"new_path" => "/admin/members/#{user.member_profile.to_param}/journal_papers/new"
|
|
}
|
|
]
|
|
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
|
|
|
|
{
|
|
"id" => j.id.to_s,
|
|
"edit_url" => "/#{I18n.locale.to_s}/admin/jounal_papers/#{j.to_param}/edit",
|
|
"paper_title" => j.paper_title,
|
|
"journal_title" => j.journal_title,
|
|
"keywords" => j.keywords,
|
|
"abstract" => j.abstract,
|
|
"files" => files
|
|
}
|
|
end
|
|
journals
|
|
end
|
|
|
|
end |