diff options
-rw-r--r-- | app/controllers/body_controller.rb | 15 | ||||
-rw-r--r-- | app/controllers/user_controller.rb | 17 | ||||
-rw-r--r-- | app/views/body/show.rhtml | 49 |
3 files changed, 53 insertions, 28 deletions
diff --git a/app/controllers/body_controller.rb b/app/controllers/body_controller.rb index 7a07daf39..e8e0780cd 100644 --- a/app/controllers/body_controller.rb +++ b/app/controllers/body_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: body_controller.rb,v 1.19 2008-10-17 11:37:59 francis Exp $ +# $Id: body_controller.rb,v 1.20 2009-03-18 02:37:42 francis Exp $ class BodyController < ApplicationController # XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL @@ -33,6 +33,19 @@ class BodyController < ApplicationController @public_body = @public_bodies[0] set_last_body(@public_body) + # Use search query for this so can collapse and paginate easily + # XXX really should just use SQL query here rather than Xapian. + begin + @xapian_requests = perform_search([InfoRequestEvent], 'requested_from:' + @public_body.url_name, 'newest', 'request_collapse') + if (@page > 1) + @page_desc = " (page " + @page.to_s + ")" + else + @page_desc = "" + end + rescue + @xapian_requests = nil + end + @track_thing = TrackThing.create_track_for_public_body(@public_body) @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss] } ] end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 38ebd076f..5809484f1 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user_controller.rb,v 1.63 2009-03-09 01:17:04 francis Exp $ +# $Id: user_controller.rb,v 1.64 2009-03-18 02:37:42 francis Exp $ class UserController < ApplicationController # Show page about a user @@ -23,21 +23,20 @@ class UserController < ApplicationController @is_you = !@user.nil? && @user.id == @display_user.id # Use search query for this so can collapse and paginate easily - # XXX really should just use SQL query here rather than Xapian. Partly - # will be more accurate, as will include backpage'd requests which - # don't appear in Xapian. + # XXX really should just use SQL query here rather than Xapian. begin @xapian_requests = perform_search([InfoRequestEvent], 'requested_by:' + @display_user.url_name, 'newest', 'request_collapse') @xapian_comments = perform_search([InfoRequestEvent], 'commented_by:' + @display_user.url_name, 'newest', nil) + + if (@page > 1) + @page_desc = " (page " + @page.to_s + ")" + else + @page_desc = "" + end rescue @xapian_requests = nil @xapian_comments = nil end - if (@page > 1) - @page_desc = " (page " + @page.to_s + ")" - else - @page_desc = "" - end # Track corresponding to this page @track_thing = TrackThing.create_track_for_user(@display_user) diff --git a/app/views/body/show.rhtml b/app/views/body/show.rhtml index c89dfd77e..be5fef30c 100644 --- a/app/views/body/show.rhtml +++ b/app/views/body/show.rhtml @@ -41,27 +41,40 @@ </strong> </div> -<% if @public_body.info_requests.empty? %> - <% if @public_body.eir_only? %> - <h2>Environmental Information Regulations requests made</h2> - <p>Nobody has made any Environmental Information Regulations requests to <%=h(@public_body.name)%> using this site.</p> +<% if !@xapian_requests.nil? %> + <% if @xapian_requests.results.empty? %> + <% if @public_body.eir_only? %> + <h2>Environmental Information Regulations requests made</h2> + <p>Nobody has made any Environmental Information Regulations requests to <%=h(@public_body.name)%> using this site yet.</p> + <% else %> + <h2>Freedom of Information requests made</h2> + <p>Nobody has made any Freedom of Information requests to <%=h(@public_body.name)%> using this site yet.</p> + <% end %> <% else %> - <h2>Freedom of Information requests made</h2> - <p>Nobody has made any Freedom of Information requests to <%=h(@public_body.name)%> using this site.</p> - <% end %> + <h2> + <% if @public_body.eir_only? %> + <%=pluralize(@public_body.info_requests.size, "Environmental Information Regulations request") %> made + <% else %> + <%=pluralize(@public_body.info_requests.size, "Freedom of Information request") %> made + <% end %> + <%= @page_desc %> + </h2> -<% else %> - <h2> - <% if @public_body.eir_only? %> - <%=pluralize(@public_body.info_requests.size, "Environmental Information Regulations request") %> made - <% else %> - <%=pluralize(@public_body.info_requests.size, "Freedom of Information request") %> made - <% end %> - </h2> + <% for result in @xapian_requests.results %> + <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %> + <% end %> - <%= render :partial => 'request/request_listing', :locals => { :info_requests => @public_body.info_requests } %> + <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @public_body.info_requests.size) %> - <p>Only requests made using WhatDoTheyKnow.com are shown.</p> + <p>Only requests made using WhatDoTheyKnow.com are shown.</p> -<% end %> + <% end %> +<% else %> + <% if @public_body.eir_only? %> + <h2>Environmental Information Regulations requests made</h2> + <% else %> + <h2>Freedom of Information requests made</h2> + <% end %> + <p>The search index is currently offline, so we can't show the Freedom of Information requests that have been made to this authority.</p> +<% end %> |