Fix announcement pagination disapeared problem.
This commit is contained in:
parent
ec5d4761a7
commit
8546eb10a4
|
@ -2,9 +2,7 @@ class AnnouncementsController < ApplicationController
|
||||||
include AnnouncementsHelper
|
include AnnouncementsHelper
|
||||||
def index
|
def index
|
||||||
Bulletin.remove_expired_status
|
Bulletin.remove_expired_status
|
||||||
announcements,sorted = get_sorted_annc
|
announcements,sorted,total_pages = get_sorted_annc
|
||||||
total_pages = sorted.total_pages
|
|
||||||
|
|
||||||
anns = []
|
anns = []
|
||||||
sorted.each do |a|
|
sorted.each do |a|
|
||||||
if !a["source-site"].present?
|
if !a["source-site"].present?
|
||||||
|
|
|
@ -93,8 +93,23 @@ module AnnouncementsHelper
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
sorted = Kaminari.paginate_array(announcements).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) rescue []
|
sorted = Kaminari.paginate_array(announcements).page(1).per(OrbitHelper.page_data_count) rescue []
|
||||||
end
|
end
|
||||||
[announcements,sorted]
|
begin
|
||||||
|
if !tags.blank?
|
||||||
|
annc_count = 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).count
|
||||||
|
else
|
||||||
|
if !params["source"].present?
|
||||||
|
annc_count = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).and(:title.ne => nil, :is_top.ne => true).can_display.is_approved.filter_by_categories(page.categories || [],false).filter_by_tags.count
|
||||||
|
annc_count += get_feed_announcements("index").count
|
||||||
|
else
|
||||||
|
annc_count = get_feed_announcements("index",params["source"]).count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
total_pages = (annc_count * 1.0 / OrbitHelper.page_data_count).ceil
|
||||||
|
rescue
|
||||||
|
total_pages = 1
|
||||||
|
end
|
||||||
|
[announcements,sorted,total_pages]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue