diff --git a/app/models/diploma.rb b/app/models/diploma.rb index 80409b9..eaba4e6 100644 --- a/app/models/diploma.rb +++ b/app/models/diploma.rb @@ -25,6 +25,8 @@ class Diploma before_validation :add_http + scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:end_date => "desc", :start_date => "desc") } + def duration if !self.start_date.nil? or !self.end_date.nil? (self.start_date.strftime('%Y.%m') rescue "")+' ~ '+(self.end_date.strftime('%Y.%m') rescue I18n.t('personal_diploma.up_to_today')) @@ -53,7 +55,7 @@ class Diploma } end - plugin_datas = datas.where(:is_hidden=>false).order_by(:end_date=>'desc', :start_date=>'desc').collect do |p| + plugin_datas = datas.sort_for_frontend.collect do |p| pd_data = [] fields_to_show.collect do |t| diff --git a/app/views/admin/diplomas/_form.html.erb b/app/views/admin/diplomas/_form.html.erb index b3944f3..9a5033f 100644 --- a/app/views/admin/diplomas/_form.html.erb +++ b/app/views/admin/diplomas/_form.html.erb @@ -119,7 +119,7 @@