personal-honor/app/controllers/personal_honors_controller.rb

43 lines
1.3 KiB
Ruby

class PersonalHonorsController < ApplicationController
def index
honors = Honor.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
honor_list = honors.collect do |honor|
{
"year" => honor.year,
"award_name" => honor.award_name,
"awarding_unit" => (honor.awarding_unit rescue ""),
"award_winner" => (honor.member_profile.name rescue ""),
"link_to_show" => OrbitHelper.url_to_show(honor.to_param)
}
end
{
"honors" => honor_list,
"extras" => {
"widget-title" => t("module_name.personal_honor"),
"th_year" => t('personal_honor.year'),
"th_award_name" => t('personal_honor.award_name'),
"th_awarding_unit" => t('personal_honor.awarding_unit'),
"th_award_winner" => t('personal_honor.award_winner'),
"th_detail" => t('detail')
},
"total_pages" => honors.total_pages
}
end
def show
params = OrbitHelper.params
plugin = Honor.where(:is_hidden=>false).find_by(uid: params[:uid])
fields_to_show = [
"year",
"honor_type",
"award_name",
"honoree",
"awarding_unit",
"keywords",
"url",
"note"
]
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
end
end