personal-honor/app/controllers/personal_honors_controller.rb

43 lines
1.3 KiB
Ruby
Raw Normal View History

2014-07-03 04:53:38 +00:00
class PersonalHonorsController < ApplicationController
def index
2014-07-18 07:03:24 +00:00
honors = Honor.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
2014-07-03 04:53:38 +00:00
honor_list = honors.collect do |honor|
{
"year" => honor.year,
"award_name" => honor.award_name,
2015-04-14 10:53:44 +00:00
"awarding_unit" => (honor.awarding_unit rescue ""),
2014-10-03 06:13:07 +00:00
"award_winner" => (honor.member_profile.name rescue ""),
2014-07-03 04:53:38 +00:00
"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')
2014-07-18 07:03:24 +00:00
},
"total_pages" => honors.total_pages
2014-07-03 04:53:38 +00:00
}
end
def show
params = OrbitHelper.params
2014-08-01 11:47:43 +00:00
plugin = Honor.where(:is_hidden=>false).find_by(uid: params[:uid])
fields_to_show = [
2015-01-09 07:44:32 +00:00
"year",
"honor_type",
2014-08-01 11:47:43 +00:00
"award_name",
"honoree",
"awarding_unit",
"keywords",
"url",
"note"
]
2014-07-03 04:53:38 +00:00
2014-08-01 11:47:43 +00:00
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
2014-07-03 04:53:38 +00:00
end
end