diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-09-20 13:38:04 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-09-20 13:38:04 +0100 |
commit | e32c63be6acd27534fb248e74e6394bf4fd8f28e (patch) | |
tree | baa2a51740fed2798d798836144458444d4fc82e /app/controllers/admin_request_controller.rb | |
parent | 6d3d9d9846fa905e606f0a2aa6f1ec32122f4850 (diff) | |
parent | 44d64c22bbd49722688a680ce89bff3d1d3a8bdb (diff) |
Merge branch 'release/0.6.6' into wdtk
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 |