Fix bug.
Add transform display year when language is chinese.
This commit is contained in:
parent
b62776f833
commit
ab332a2c3d
|
@ -32,7 +32,7 @@ class AcademicAdvisingsController < ApplicationController
|
|||
when "award_name"
|
||||
t << {"value" => "<a href='#{OrbitHelper.url_to_show(academic_advising.to_param)}'>" + (academic_advising.send(fs) rescue "") + "</a>"}
|
||||
when "academic_advising_type"
|
||||
t << {"value" => (academic_advising.send("academic_advising_type").title rescue "")}
|
||||
t << {"value" => academic_advising.display_advising_type}
|
||||
when "authors"
|
||||
member_profile = academic_advising.send(:member_profile)
|
||||
role_status_id = member_profile.role_status_ids.first.to_s
|
||||
|
@ -42,6 +42,8 @@ class AcademicAdvisingsController < ApplicationController
|
|||
t << {"value" => (academic_advising.send(fs).strftime("%Y/%m") rescue "")}
|
||||
when "advising_students"
|
||||
t << {"value" => academic_advising.advising_students_front_data}
|
||||
when "year"
|
||||
t << {"value" => academic_advising.display_year}
|
||||
else
|
||||
t << {"value" => (academic_advising.send(fs) rescue "")}
|
||||
end
|
||||
|
|
|
@ -181,7 +181,7 @@ class Admin::AcademicAdvisingsController < OrbitMemberController
|
|||
end
|
||||
|
||||
def set_plugin
|
||||
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'AcademicAdvising'}.first
|
||||
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Advising'}.first
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -25,7 +25,12 @@ class Advising
|
|||
before_validation :add_http
|
||||
|
||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc",:award_date => "desc") }
|
||||
|
||||
def display_year
|
||||
(I18n.locale.to_s == "zh_tw" ? (self.year > 1911 ? (self.year - 1911) : self.year ) : self.year)
|
||||
end
|
||||
def display_advising_type
|
||||
(self.advising_type ? self.advising_type.title : "")
|
||||
end
|
||||
def slug_title
|
||||
self.award_name+' '+self.awarding_unit rescue ""
|
||||
end
|
||||
|
@ -51,8 +56,8 @@ class Advising
|
|||
fields_to_show = page.custom_array_field
|
||||
else
|
||||
fields_to_show = [
|
||||
"academic_advising_type",
|
||||
"year",
|
||||
"academic_advising_type",
|
||||
"award_name",
|
||||
"awarding_unit",
|
||||
"advising_students"
|
||||
|
@ -62,12 +67,13 @@ class Advising
|
|||
fields_to_remove = []
|
||||
|
||||
pd_title = []
|
||||
puts fields_to_show
|
||||
fields_to_show.each do |t|
|
||||
if (self.fields[t].type.to_s == "String" || self.fields[t].type.to_s == "Object" rescue false)
|
||||
fields_to_remove << t if (datas.where(t.to_sym.ne => nil, t.to_sym.ne => "").count == 0 rescue false)
|
||||
elsif t=='advising_students'
|
||||
fields_to_remove << t if (datas.where(:advising_student_ids.ne => []).count == 0 rescue false)
|
||||
elsif t == "academic_advising_type"
|
||||
fields_to_remove << t if (datas.where(:advising_type.ne => nil).count == 0 rescue false)
|
||||
else
|
||||
fields_to_remove << t if (datas.where(t.to_sym.ne => nil).count == 0 rescue false)
|
||||
end
|
||||
|
@ -75,7 +81,7 @@ class Advising
|
|||
"plugin_data_title" => I18n.t("academic_advising.#{t}")
|
||||
} if !fields_to_remove.include?(t)
|
||||
end
|
||||
|
||||
puts fields_to_remove
|
||||
fields_to_show = fields_to_show - fields_to_remove
|
||||
|
||||
plugin_datas = datas.sort_for_frontend.collect.with_index do |p,index|
|
||||
|
@ -84,11 +90,13 @@ class Advising
|
|||
if t == "award_name"
|
||||
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'academic_advising')}' title='#{p.send(t)}' target='_blank'>#{p.send(t)}</a>" }
|
||||
elsif t == "academic_advising_type"
|
||||
pd_data << {"data_title" => (p.academic_advising_type.title rescue "")}
|
||||
pd_data << {"data_title" => p.display_advising_type}
|
||||
elsif t == "award_date"
|
||||
pd_data << {"data_title" => (p.send(t).strftime("%Y/%m/%d") rescue "")}
|
||||
elsif t == "advising_students"
|
||||
pd_data << {"data_title" => p.advising_students_front_data}
|
||||
elsif t == "year"
|
||||
pd_data << { "data_title" => p.display_year }
|
||||
else
|
||||
pd_data << { "data_title" => p.send(t) }
|
||||
end
|
||||
|
@ -113,11 +121,13 @@ class Advising
|
|||
when "language"
|
||||
value = I18n.t(self.language) rescue ""
|
||||
when "academic_advising_type"
|
||||
value = self.academic_advising_type.title rescue ""
|
||||
value = self.display_advising_type
|
||||
when "award_date"
|
||||
value = self.award_date.strftime("%Y/%m/%d") rescue ""
|
||||
when "advising_students"
|
||||
value = self.advising_students_front_data
|
||||
when "year"
|
||||
value = self.display_year
|
||||
else
|
||||
value = self.send(field) rescue ""
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<% @academic_advisings.each do |academic_advising| %>
|
||||
<tr id="<%= dom_id academic_advising %>" class="<%= academic_advising.is_hidden ? "checkHide" : "" %>">
|
||||
<td><%= academic_advising.year %></td>
|
||||
<td><%= academic_advising.display_year %></td>
|
||||
<td><%= academic_advising.display_advising_type %></td>
|
||||
<td>
|
||||
<%= link_to academic_advising.award_name, OrbitHelper.url_to_plugin_show(academic_advising.to_param,'academic_advising'), target: "blank"%>
|
||||
<div class="quick-edit">
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th class="span3"><%= t('academic_advising.year') %></th>
|
||||
<th class="span3"><%= t('academic_advising.academic_advising_type') %></th>
|
||||
<th class="span3"><%= t('academic_advising.award_name') %></th>
|
||||
<th class="span3"><%= t('academic_advising.awarding_unit') %></th>
|
||||
<th class="span3"><%= t('academic_advising.academic_advisingee') %></th>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<th><input type="checkbox" /></th>
|
||||
<% end -%>
|
||||
<th class="span3"><%= t('academic_advising.year') %></th>
|
||||
<th class="span3"><%= t('academic_advising.academic_advising_type') %></th>
|
||||
<th class="span3"><%= t('academic_advising.award_name') %></th>
|
||||
<th class="span3"><%= t('academic_advising.awarding_unit') %></th>
|
||||
<th class="span3"><%= t('academic_advising.award_winner') %></th>
|
||||
|
@ -42,7 +43,8 @@
|
|||
<%= check_box_tag 'to_change[]', academic_advising.id.to_s, false, :class => "list-check" %>
|
||||
</td>
|
||||
<% end %>
|
||||
<td><%= academic_advising.year %></td>
|
||||
<td><%= academic_advising.display_year %></td>
|
||||
<td><%= academic_advising.display_advising_type %></td>
|
||||
<td>
|
||||
<%= link_to academic_advising.award_name, OrbitHelper.url_to_plugin_show(academic_advising.to_param,'academic_advising'), target: "blank"%>
|
||||
<div class="quick-edit">
|
||||
|
|
|
@ -4,7 +4,7 @@ module AcademicAdvising
|
|||
OrbitApp.registration "AcademicAdvising",:type=> 'ModuleApp' do
|
||||
module_label 'module_name.academic_advising'
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
personal_plugin :enable => true, :sort_number => '50', :app_name=>"Advising", :intro_app_name=>"AdvisingIntro",:path=>"/plugin/academic_advising/profile",:front_path=>"/profile",:admin_path=>"/admin/academic_advisings",:i18n=>'module_name.academic_advising', :module_app_name=>'AcademicAdvising', :field_modifiable => true, :analysis => true, :analysis_path => "/admin/academic_advisings/analysis"
|
||||
personal_plugin :enable => true, :sort_number => '50', :app_name=>"Advising", :intro_app_name=>"AdvisingIntro",:path=>"/plugin/academic_advising/profile",:front_path=>"/profile",:admin_path=>"/admin/academic_advisings/",:i18n=>'module_name.academic_advising', :module_app_name=>'AcademicAdvising', :field_modifiable => true, :analysis => true, :analysis_path => "/admin/academic_advisings/analysis"
|
||||
|
||||
version "0.1"
|
||||
desktop_enabled true
|
||||
|
|
Loading…
Reference in New Issue