personal-patent/app/controllers/personal_patents_controller.rb

72 lines
2.5 KiB
Ruby

class PersonalPatentsController < ApplicationController
def index
patents = Patent.where(:is_hidden=>false).all
patent_list = patents.collect do |patent|
{
"publication_date" => patent.publication_date,
"patent_title" => patent.patent_title,
"patent_no" => patent.patent_no,
"patent_country" => patent.patent_country,
"authors" => patent.member_profile.name,
"link_to_show" => OrbitHelper.url_to_show(patent.to_param)
}
end
{
"patents" => patent_list,
"extras" => {
"widget-title" => t("personal_patent.personal_patent"),
"th_publication_date" => t('personal_patent.publication_date'),
"th_patent_title" => t("personal_patent.paper_patent_title"),
"th_patent_no" => t('personal_patent.patent_no'),
"th_patent_country" => t("personal_patent.paper_patent_country"),
"th_authors" => t('user.name')
}
}
end
def show
params = OrbitHelper.params
patent = Patent.where(:is_hidden=>false).find_by(uid: params[:uid])
files = patent.patent_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" => {
"patent_title" => patent.patent_title,
"patent_type" => patent.patent_type.title,
"authors" => patent.authors,
"year" => patent.year,
"language" => t(patent.language),
"keywords" => patent.keywords,
"patent_no" => patent.patent_no,
"patent_country" => patent.patent_country,
"publish_date" => patent.publish_date.strftime("%Y.%m"),
"url" => patent.url,
"note" => patent.note,
"th_patent_title" => t("personal_patent.patent_title"),
"th_authors" => t("personal_patent.authors"),
"th_year" => t("personal_patent.year"),
"th_language" => t("personal_patent.language"),
"th_keywords" => t("personal_patent.keywords"),
"th_patent_no" => t("personal_patent.patent_no"),
"th_patent_country" => t("personal_patent.patent_country"),
"th_publish_date" => t("personal_patent.publication_date"),
"th_url" => t("personal_patent.url"),
"th_note" => t("personal_patent.note"),
"th_patent_type" => t("personal_patent.patent_category"),
"th_files" => t(:file_)
}
}
end
end