personal-patent/app/controllers/personal_patents_controller.rb

73 lines
2.7 KiB
Ruby
Raw Normal View History

2014-07-04 03:48:33 +00:00
class PersonalPatentsController < ApplicationController
def index
2014-07-18 07:05:27 +00:00
patents = Patent.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
2014-07-04 03:48:33 +00:00
patent_list = patents.collect do |patent|
{
2014-07-04 03:55:31 +00:00
"publication_date" => patent.publish_date,
2014-07-04 03:48:33 +00:00
"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" => {
2014-07-04 03:55:31 +00:00
"widget-title" => t("module_name.personal_patent"),
2014-07-04 03:48:33 +00:00
"th_publication_date" => t('personal_patent.publication_date'),
2014-07-04 03:55:31 +00:00
"th_patent_title" => t("personal_patent.patent_title"),
2014-07-04 03:48:33 +00:00
"th_patent_no" => t('personal_patent.patent_no'),
2014-07-04 03:55:31 +00:00
"th_patent_country" => t("personal_patent.patent_country"),
"th_authors" => t('users.name')
2014-07-18 07:05:27 +00:00
},
"total_pages" => patents.total_pages
2014-07-04 03:48:33 +00:00
}
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,
2014-07-15 11:09:28 +00:00
"patent_type" => (patent.patent_type.title rescue ""),
2014-07-04 03:48:33 +00:00
"authors" => patent.authors,
"year" => patent.year,
2014-07-15 11:09:28 +00:00
"language" => (t(patent.language) rescue ""),
2014-07-04 03:48:33 +00:00
"keywords" => patent.keywords,
"patent_no" => patent.patent_no,
"patent_country" => patent.patent_country,
2014-07-15 11:09:28 +00:00
"publish_date" => (patent.publish_date.strftime("%Y.%m") rescue ""),
2014-07-04 03:48:33 +00:00
"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