personal-project/app/controllers/personal_projects_controlle...

75 lines
2.7 KiB
Ruby
Raw Normal View History

2014-07-04 06:14:37 +00:00
class PersonalProjectsController < ApplicationController
def index
2014-07-18 07:06:04 +00:00
projects = Project.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
2014-07-04 06:14:37 +00:00
project_list = projects.collect do |project|
{
"duration" => project.duration,
"project_title" => project.project_title,
"job_title" => project.job_title,
"participator" => project.participator,
"authors" => project.member_profile.name,
"link_to_show" => OrbitHelper.url_to_show(project.to_param)
}
end
{
"projects" => project_list,
"extras" => {
"widget-title" => t("module_name.personal_project"),
"th_duration" => t('personal_project.period'),
"th_project_title" => t("personal_project.project_title"),
"th_job_title" => t('personal_project.job_title'),
"th_participator" => t("personal_project.participator"),
"th_authors" => t('users.name')
2014-07-18 07:06:04 +00:00
},
"total_pages" => projects.total_pages
2014-07-04 06:14:37 +00:00
}
end
def show
params = OrbitHelper.params
project = Project.where(:is_hidden=>false).find_by(uid: params[:uid])
files = project.project_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" => {
"project_title" => project.project_title,
"project_type" => project.project_type.title,
"job_title" => project.job_title,
"participator" => project.participator,
"unit" => project.unit,
"year" => project.year,
"language" => project.language,
"keywords" => project.keywords,
"abstract" => project.abstract,
"duration" => project.duration,
"url" => project.url,
"note" => project.note,
"th_project_title" => t("personal_project.project_title"),
"th_job_title" => t("personal_project.job_title"),
"th_participator" => t("personal_project.participator"),
"th_unit" => t("personal_project.unit"),
"th_year" => t("personal_project.year"),
"th_language" => t("personal_project.language"),
"th_keywords" => t("personal_project.keywords"),
"th_abstract" => t("personal_project.abstract"),
"th_duration" => t("personal_project.period"),
"th_url" => t("personal_project.url"),
"th_note" => t("personal_project.note"),
"th_project_type" => t("personal_project.project_category"),
"th_files" => t(:file_)
}
}
end
end