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

92 lines
3.1 KiB
Ruby

class PersonalProjectsController < ApplicationController
def index
projects = Project.where(:is_hidden=>false).order_by(:period_start_date=>'desc',:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
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 rescue ""),
"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')
},
"total_pages" => projects.total_pages
}
end
def show
params = OrbitHelper.params
plugin = Project.where(:is_hidden=>false).find_by(uid: params[:uid])
fields_to_show = [
"project_title",
"project_type",
"job_title",
"participator",
"unit",
"year",
"language",
"keywords",
"abstract",
"period",
"url",
"note",
"file"
]
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
# 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