forked from saurabh/personal-diploma
sorting and dates fixed
This commit is contained in:
parent
3672de450f
commit
93043e5ba0
|
@ -25,6 +25,8 @@ class Diploma
|
||||||
|
|
||||||
before_validation :add_http
|
before_validation :add_http
|
||||||
|
|
||||||
|
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:end_date => "desc", :start_date => "desc") }
|
||||||
|
|
||||||
def duration
|
def duration
|
||||||
if !self.start_date.nil? or !self.end_date.nil?
|
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'))
|
(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
|
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 = []
|
pd_data = []
|
||||||
fields_to_show.collect do |t|
|
fields_to_show.collect do |t|
|
||||||
|
|
|
@ -119,7 +119,7 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted"><%= t("personal_diploma.start_date") %></label>
|
<label class="control-label muted"><%= t("personal_diploma.start_date") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.datetime_picker :start_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM" %>
|
<%= f.datetime_picker :start_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM", :value => @diploma.start_date, :new_record => @diploma.new_record? %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted"><%= t("personal_diploma.end_date") %></label>
|
<label class="control-label muted"><%= t("personal_diploma.end_date") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.datetime_picker :end_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM" %>
|
<%= f.datetime_picker :end_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM", :value => @diploma.end_date, :new_record => @diploma.new_record? %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue