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

74 lines
2.6 KiB
Ruby

class PersonalProjectsController < ApplicationController
def index
projects = Project.where(:is_hidden=>false).all
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')
}
}
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