added scope for index

This commit is contained in:
Harry Bomrah 2016-04-11 19:27:06 +08:00
parent 7ce95b75ba
commit ea7ddc5339
1 changed files with 12 additions and 12 deletions

View File

@ -1,7 +1,7 @@
class PersonalTechnologyTransfersController < ApplicationController class PersonalTechnologyTransfersController < ApplicationController
def index def index
params = OrbitHelper.params params = OrbitHelper.params
tts = TechnologyTransfer.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) tts = TechnologyTransfer.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
fields_to_show = Page.where(:page_id => params[:page_id]).first.custom_array_field rescue [] fields_to_show = Page.where(:page_id => params[:page_id]).first.custom_array_field rescue []
if fields_to_show.blank? if fields_to_show.blank?
@ -22,17 +22,17 @@ class PersonalTechnologyTransfersController < ApplicationController
t = [] t = []
fields_to_show.each do |fs| fields_to_show.each do |fs|
case fs case fs
when "title" when "title"
t << {"value" => "<a href='#{OrbitHelper.url_to_show(tt.to_param)}'>" + (tt.send(fs) rescue "") + "</a>"} t << {"value" => "<a href='#{OrbitHelper.url_to_show(tt.to_param)}'>" + (tt.send(fs) rescue "") + "</a>"}
when "category" when "category"
t << {"value" => (tt.send("technology_transfer_category").title rescue "")} t << {"value" => (tt.send("technology_transfer_category").title rescue "")}
when "authors" when "authors"
t << {"value" => (tt.send(:member_profile).name rescue "")} t << {"value" => (tt.send(:member_profile).name rescue "")}
when "patent_granted" when "patent_granted"
t << {"value" => (tt.patent_granted ? t("personal_technology_transfer.y_es") : t("personal_technology_transfer.n_o"))} t << {"value" => (tt.patent_granted ? t("personal_technology_transfer.y_es") : t("personal_technology_transfer.n_o"))}
else else
t << {"value" => (tt.send(fs) rescue "")} t << {"value" => (tt.send(fs) rescue "")}
end end
end end
tts_list << {"technology_transfers" => t} tts_list << {"technology_transfers" => t}
end end