added postdate search filter in announcement
This commit is contained in:
parent
cf5c45cb34
commit
370f3fd325
|
@ -9,7 +9,6 @@ class AnnouncementsController < ApplicationController
|
||||||
if !params['tags'].blank?
|
if !params['tags'].blank?
|
||||||
announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).and(:title.ne => nil).can_display.is_approved.filter_by_tags(params['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_tags(params['tags']).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count).to_a
|
||||||
else
|
else
|
||||||
|
|
||||||
if !params["source"].present?
|
if !params["source"].present?
|
||||||
announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).and(:title.ne => nil, :is_top.ne => true).can_display.is_approved.filter_by_categories([],false).filter_by_tags.to_a
|
announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).and(:title.ne => nil, :is_top.ne => true).can_display.is_approved.filter_by_categories([],false).filter_by_tags.to_a
|
||||||
feeds_anns = get_feed_announcements("index")
|
feeds_anns = get_feed_announcements("index")
|
||||||
|
@ -40,12 +39,28 @@ class AnnouncementsController < ApplicationController
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
if params["postdate"].present?
|
||||||
|
sorted = sorted.find_all{|anns|
|
||||||
|
if anns["source-site"].present?
|
||||||
|
/#{params[:postdate].to_s}/i.match anns["postdate"].strftime("%Y-%m") if !anns["postdate"].nil?
|
||||||
|
else
|
||||||
|
/#{params[:postdate].to_s}/i.match anns.postdate.strftime("%Y-%m") if !anns.postdate.nil?
|
||||||
|
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
|
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
|
||||||
|
if params["postdate"].present?
|
||||||
|
announcements = announcements.find_all{|anns|
|
||||||
|
if !anns.postdate.nil?
|
||||||
|
/#{params[:postdate].to_s}/i.match anns.postdate.strftime("%Y-%m")
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
sorted = Kaminari.paginate_array(announcements).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) rescue []
|
sorted = Kaminari.paginate_array(announcements).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) rescue []
|
||||||
end
|
end
|
||||||
total_pages = sorted.total_pages
|
total_pages = sorted.total_pages
|
||||||
|
|
Loading…
Reference in New Issue