aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2009-03-03 22:37:58 +0000
committerfrancis <francis>2009-03-03 22:37:58 +0000
commit80bb95a68258c76b8d4c9af66a1105c96e410424 (patch)
tree9795cda46d1ac8595ac6302657aaa2ee1559e956
parent528f967463cfbb8a9e5c4eff53e1388c92f48e6a (diff)
Patch from Tony Bowden to show the user page even if Xapian setup broken.
-rw-r--r--app/controllers/user_controller.rb11
-rw-r--r--app/views/user/show.rhtml76
2 files changed, 50 insertions, 37 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index e69b47c29..5196096ef 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.60 2008-09-21 23:53:50 francis Exp $
+# $Id: user_controller.rb,v 1.61 2009-03-03 22:37:58 francis Exp $
class UserController < ApplicationController
# Show page about a user
@@ -26,8 +26,13 @@ class UserController < ApplicationController
# 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.
- @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)
+ 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)
+ rescue
+ @xapian_requests = nil
+ @xapian_comments = nil
+ end
if (@page > 1)
@page_desc = " (page " + @page.to_s + ")"
else
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index ce8b510c4..3055c85d1 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -82,45 +82,53 @@
<% end %>
<% end %>
- <% if @xapian_requests.results.empty? %>
- <% if @page == 1 %>
- <h2>Freedom of Information requests made by <%= @is_you ? 'you' : 'this person' %> </h2>
- <p><%= @is_you ? 'You have' : 'This person has' %>
- made no Freedom of Information requests using this site.</p>
- <% end %>
- <% else %>
- <h2>
- <%= @is_you ? 'Your ' : "This person's " %>
- <%=pluralize(@display_user.info_requests.size, "Freedom of Information request") %>
- <!-- matches_estimated <%=@xapian_requests.matches_estimated%> -->
- <%= @page_desc %>
- </h2>
+ <% if !@xapian_requests.nil? %>
+ <% if @xapian_requests.results.empty? %>
+ <% if @page == 1 %>
+ <h2>Freedom of Information requests made by <%= @is_you ? 'you' : 'this person' %> </h2>
+ <p><%= @is_you ? 'You have' : 'This person has' %>
+ made no Freedom of Information requests using this site.</p>
+ <% end %>
+ <% else %>
+ <h2>
+ <%= @is_you ? 'Your ' : "This person's " %>
+ <%=pluralize(@display_user.info_requests.size, "Freedom of Information request") %>
+ <!-- matches_estimated <%=@xapian_requests.matches_estimated%> -->
+ <%= @page_desc %>
+ </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 %>
- <% for result in @xapian_requests.results %>
- <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
+ <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.info_requests.size) %>
<% end %>
+ <% else %>
+ <h2>Freedom of Information requests made by <%= @is_you ? 'you' : 'this person' %> </h2>
+ <p>The search index is currently offline, so we can't show the Freedom of Information requests this person has made.</p>
+ <% end %>
- <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.info_requests.size) %>
- <% end %>
-
- <% if @xapian_comments.results.empty? %>
- <% if @page == 1 %>
- <h2><%= @is_you ? 'Your' : 'This person\'s' %> annotations </h2>
- <p>None made.</p>
- <% end %>
- <% else %>
- <h2>
- <%= @is_you ? 'Your ' : "This person's " %>
- <%=pluralize(@display_user.visible_comments.size, "annotation") %>
- <!-- matches_estimated <%=@xapian_comments.matches_estimated%> -->
- <%= @page_desc %>
- </h2>
+ <% if !@xapian_comments.nil? %>
+ <% if @xapian_comments.results.empty? %>
+ <% if @page == 1 %>
+ <h2><%= @is_you ? 'Your' : 'This person\'s' %> annotations </h2>
+ <p>None made.</p>
+ <% end %>
+ <% else %>
+ <h2>
+ <%= @is_you ? 'Your ' : "This person's " %>
+ <%=pluralize(@display_user.visible_comments.size, "annotation") %>
+ <!-- matches_estimated <%=@xapian_comments.matches_estimated%> -->
+ <%= @page_desc %>
+ </h2>
+
+ <% for result in @xapian_comments.results %>
+ <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
+ <% end %>
- <% for result in @xapian_comments.results %>
- <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
+ <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.visible_comments.size) %>
<% end %>
-
- <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.visible_comments.size) %>
<% end %>
+
</div>