personal-research/app/controllers/personal_researches_control...

66 lines
2.5 KiB
Ruby
Raw Normal View History

2014-07-04 07:18:31 +00:00
class PersonalResearchesController < ApplicationController
def index
2014-07-18 07:06:41 +00:00
researchs = Research.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
2014-07-04 07:18:31 +00:00
research_list = researchs.collect do |research|
{
"member" => research.member_profile.name,
"year" => research.year,
2014-07-18 07:06:41 +00:00
"publication_date" => (research.publish_date.strftime("%Y.%m") rescue ""),
2014-07-04 07:18:31 +00:00
"research_title" => research.research_title,
"link_to_show" => OrbitHelper.url_to_show(research.to_param)
}
end
{
"researchs" => research_list,
"extras" => {
"widget-title" => t("module_name.personal_research"),
"th_member" => t('users.name'),
"th_year" => t('personal_research.year'),
"th_publication_date" => t('personal_research.publication_date'),
"th_research_title" => t('personal_research.research_title'),
"th_detail" => t('detail')
2014-07-18 07:06:41 +00:00
},
"total_pages" => researchs.total_pages
2014-07-04 07:18:31 +00:00
}
end
def show
params = OrbitHelper.params
research = Research.where(:is_hidden=>false).find_by(uid: params[:uid])
files = research.research_files.map do |file|
{
"file_url" => file.file.url,
"file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title),
"file_ext" => File.extname(file.file.path).sub('.',''),
"file_description" => file.description
}
end
{
"files" => files,
"data" => {
"research_title" => research.research_title,
"authors" => research.authors,
"extracted_chapters" => research.extracted_chapters,
"year" => research.year,
"language" => t(research.language),
2014-07-18 07:06:41 +00:00
"publish_date" => (research.publish_date.strftime("%Y.%m") rescue ""),
2014-07-04 07:18:31 +00:00
"keywords" => research.keywords,
"url" => research.url,
"note" => research.note,
"th_research_title" => t("personal_research.research_title"),
"th_authors" => t("personal_research.authors"),
"th_extracted_chapters" => t("personal_research.extracted_chapters"),
"th_year" => t("personal_research.year"),
"th_language" => t("personal_research.language"),
"th_publish_date" => t("personal_research.publication_date"),
"th_keywords" => t("personal_research.keywords"),
"th_url" => t("personal_research.url"),
"th_note" => t("personal_research.note"),
"th_files" => t(:file_)
}
}
end
end