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
|
locale = OrbitHelper.get_site_locale.to_s
|
||||||
page = Page.where(url:params['url']).first
|
page = Page.where(url:params['url']).first
|
||||||
feeds_anns = []
|
feeds_anns = []
|
||||||
top_anns = []
|
|
||||||
tags = page.tags
|
tags = page.tags
|
||||||
if !tags.blank?
|
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
|
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
|
||||||
end
|
end
|
||||||
# (OrbitHelper.page_number == 1 or OrbitHelper.page_number.nil?) &&
|
# (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?
|
if !feeds_anns.blank?
|
||||||
announcements = announcements.concat(feeds_anns)
|
announcements = announcements.concat(feeds_anns)
|
||||||
sorted = announcements.sort{ |k,v| v["postdate"] <=> k["postdate"] }
|
sorted = announcements.sort{ |k,v| v["postdate"] <=> k["postdate"] }
|
||||||
sorted = top_anns + sorted
|
|
||||||
if params["keywords"].present?
|
if params["keywords"].present?
|
||||||
sorted = sorted.find_all{|anns|
|
sorted = sorted.find_all{|anns|
|
||||||
if anns["source-site"].present?
|
if anns["source-site"].present?
|
||||||
|
@ -93,7 +83,6 @@ module AnnouncementsHelper
|
||||||
end
|
end
|
||||||
sorted = Kaminari.paginate_array(sorted).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) rescue []
|
sorted = Kaminari.paginate_array(sorted).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) rescue []
|
||||||
else
|
else
|
||||||
announcements = top_anns + announcements
|
|
||||||
if params["keywords"].present?
|
if params["keywords"].present?
|
||||||
announcements = announcements.find_all{|anns| /#{params[:keywords].to_s}/i.match anns.title}
|
announcements = announcements.find_all{|anns| /#{params[:keywords].to_s}/i.match anns.title}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue