diff --git a/app/controllers/personal_honors_controller.rb b/app/controllers/personal_honors_controller.rb index 853e580..b0ae582 100644 --- a/app/controllers/personal_honors_controller.rb +++ b/app/controllers/personal_honors_controller.rb @@ -18,22 +18,22 @@ class PersonalHonorsController < ApplicationController honors.each do |honor| t = [] fields_to_show.each do |fs| - case fs - when "award_name" - t << {"value" => "" + (honor.send(fs) rescue "") + ""} - when "honor_type" - t << {"value" => (honor.send("honor_type").title rescue "")} - when "authors" - t << {"value" => (honor.send(:member_profile).name rescue "")} - when "award_date" - t << {"value" => (honor.send(fs).strftime("%Y/%m") rescue "")} - else - t << {"value" => (honor.send(fs) rescue "")} - end - end - honor_list << {"personal_honors" => t} + case fs + when "award_name" + t << {"value" => "" + (honor.send(fs) rescue "") + ""} + when "honor_type" + t << {"value" => (honor.send("honor_type").title rescue "")} + when "authors" + t << {"value" => (honor.send(:member_profile).name rescue "")} + when "award_date" + t << {"value" => (honor.send(fs).strftime("%Y/%m") rescue "")} + else + t << {"value" => (honor.send(fs) rescue "")} + end + end + honor_list << {"personal_honors" => t} end - + headers = [] fields_to_show.each do |fs| col = 2 @@ -73,35 +73,35 @@ class PersonalHonorsController < ApplicationController end def get_fields_for_index - @page = Page.find(params[:page_id]) rescue nil - @fields_to_show = [ - "year", - "award_name", - "awarding_unit", - "honor_type", - "award_date", - "country", - "keywords", - "url", - "note", - "authors", - "award_winner" - ] - @fields_to_show = @fields_to_show.map{|fs| [(fs == "authors" ? t("users.name") : t("personal_honor.#{fs}")), fs]} - @default_fields_to_show = [ - "honor_type", - "year", - "award_name", - "authors", - "awarding_unit" - ] - render :layout => false + @page = Page.find(params[:page_id]) rescue nil + @fields_to_show = [ + "year", + "award_name", + "awarding_unit", + "honor_type", + "award_date", + "country", + "keywords", + "url", + "note", + "authors", + "award_winner" + ] + @fields_to_show = @fields_to_show.map{|fs| [(fs == "authors" ? t("users.name") : t("personal_honor.#{fs}")), fs]} + @default_fields_to_show = [ + "honor_type", + "year", + "award_name", + "authors", + "awarding_unit" + ] + render :layout => false end def save_index_fields - page = Page.find(params[:page_id]) rescue nil - page.custom_array_field = params[:keys] - page.save - render :json => {"success" => true}.to_json + page = Page.find(params[:page_id]) rescue nil + page.custom_array_field = params[:keys] + page.save + render :json => {"success" => true}.to_json end -end \ No newline at end of file +end