diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-09-13 14:50:10 +0100 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-09-13 14:50:10 +0100 |
commit | 77fdd7cd39bd6166932eb5286b251de79de0a57d (patch) | |
tree | f63e86efd270a5872b0a81e3495e3e63bbaa8c8f /app/controllers/admin_request_controller.rb | |
parent | 0bf0be30cfbb866727a98ae22444aa0a724288b1 (diff) | |
parent | a622b31a33658696525ad675cdeb1e433f2a7c8b (diff) |
Merge branch 'develop' of git.mysociety.org:/data/git/public/alaveteli into develop
Diffstat (limited to 'app/controllers/admin_request_controller.rb')
-rw-r--r-- | app/controllers/admin_request_controller.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index c5abf8769..7cf23e61e 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -16,12 +16,25 @@ class AdminRequestController < AdminController def list @query = params[:query] - @info_requests = InfoRequest.paginate :order => "created_at desc", :page => params[:page], :per_page => 100, + @info_requests = InfoRequest.paginate :order => "created_at desc", + :page => params[:page], + :per_page => 100, :conditions => @query.nil? ? nil : ["lower(title) like lower('%'||?||'%')", @query] end def list_old_unclassified - @info_requests = InfoRequest.find_old_unclassified(:conditions => ["prominence = 'normal'"]) + @info_requests = WillPaginate::Collection.create((params[:page] or 1), 50) do |pager| + info_requests = InfoRequest.find_old_unclassified(:conditions => ["prominence = 'normal'"], + :limit => pager.per_page, + :offset => pager.offset) + # inject the result array into the paginated collection: + pager.replace(info_requests) + + unless pager.total_entries + # the pager didn't manage to guess the total count, do it manually + pager.total_entries = InfoRequest.count_old_unclassified(:conditions => ["prominence = 'normal'"]) + end + end end def show |