fix announcment sorting
This commit is contained in:
parent
5ed776b0ca
commit
cf1888272e
|
@ -229,14 +229,16 @@ class AnnouncementsController < ApplicationController
|
|||
end
|
||||
if @tab_option == 0
|
||||
anns = get_anncs_for_pack_data(cats,tags,nil,is_random)
|
||||
later_process = false
|
||||
else
|
||||
later_process = true
|
||||
if cats.count != 1 || tags == ["all"]
|
||||
cats.each do |cat|
|
||||
anns = anns + get_anncs_for_pack_data([cat],tags,'',is_random)
|
||||
anns = anns + get_anncs_for_pack_data([cat],tags,'',is_random, later_process)
|
||||
end
|
||||
else
|
||||
tags.each do |tag|
|
||||
anns = anns + get_anncs_for_pack_data(cats,[tag],tag,is_random)
|
||||
anns = anns + get_anncs_for_pack_data(cats,[tag],tag,is_random, later_process)
|
||||
end
|
||||
use_tag = true
|
||||
end
|
||||
|
@ -250,6 +252,7 @@ class AnnouncementsController < ApplicationController
|
|||
cats = ["all"] + cats
|
||||
end
|
||||
anns = sort_announcements(anns)
|
||||
process_anns(anns)
|
||||
end
|
||||
cats = cats.uniq
|
||||
tags = tags.uniq
|
||||
|
@ -545,7 +548,10 @@ class AnnouncementsController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
def get_anncs_for_pack_data(cats,tags,set_tags=nil,is_random = false)
|
||||
def process_anns(anns)
|
||||
anns.each{|a| a["postdate"] = a["postdate"].in_time_zone(Time.zone.utc_offset / 3600).strftime('%Y-%m-%d %H:%M') if a["postdate"] }
|
||||
end
|
||||
def get_anncs_for_pack_data(cats,tags,set_tags=nil,is_random = false,later_process=false)
|
||||
if @annc_depts.nil?
|
||||
@annc_depts = []
|
||||
@tmp_enable_annc_dept = (enable_annc_dept rescue false)
|
||||
|
@ -624,7 +630,9 @@ class AnnouncementsController < ApplicationController
|
|||
anns = top_anns + rest_anns
|
||||
end
|
||||
end
|
||||
anns.each{|a| a["postdate"] = a["postdate"].in_time_zone(Time.zone.utc_offset / 3600).strftime('%Y-%m-%d %H:%M') if a["postdate"] }
|
||||
unless later_process
|
||||
process_anns(anns)
|
||||
end
|
||||
anns
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue