Fix is_top's Bulletin repeated appear in index pages.
This commit is contained in:
parent
91346e6fe2
commit
4e21213602
|
@ -47,7 +47,6 @@ module AnnouncementsHelper
|
|||
locale = OrbitHelper.get_site_locale.to_s
|
||||
page = Page.where(url:params['url']).first
|
||||
feeds_anns = []
|
||||
top_anns = []
|
||||
tags = page.tags
|
||||
if !tags.blank?
|
||||
announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).and(:title.ne => nil).can_display.is_approved.filter_by_categories(page.categories || [],false).filter_by_tags(tags).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count).to_a
|
||||
|
@ -61,18 +60,9 @@ module AnnouncementsHelper
|
|||
end
|
||||
end
|
||||
# (OrbitHelper.page_number == 1 or OrbitHelper.page_number.nil?) &&
|
||||
if !params["source"].present?
|
||||
if !tags.blank?
|
||||
top_anns = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil], :is_top => true).and(:title.ne => nil).can_display.filter_by_categories(page.categories || [],false).filter_by_tags(tags).to_a
|
||||
else
|
||||
top_anns = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil], :is_top => true).and(:title.ne => nil).can_display.filter_by_categories(page.categories || [],false).filter_by_tags.to_a
|
||||
end
|
||||
end
|
||||
|
||||
if !feeds_anns.blank?
|
||||
announcements = announcements.concat(feeds_anns)
|
||||
sorted = announcements.sort{ |k,v| v["postdate"] <=> k["postdate"] }
|
||||
sorted = top_anns + sorted
|
||||
if params["keywords"].present?
|
||||
sorted = sorted.find_all{|anns|
|
||||
if anns["source-site"].present?
|
||||
|
@ -93,7 +83,6 @@ module AnnouncementsHelper
|
|||
end
|
||||
sorted = Kaminari.paginate_array(sorted).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) rescue []
|
||||
else
|
||||
announcements = top_anns + announcements
|
||||
if params["keywords"].present?
|
||||
announcements = announcements.find_all{|anns| /#{params[:keywords].to_s}/i.match anns.title}
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue