aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2012-10-17 17:33:20 +0100
committerLouise Crow <louise.crow@gmail.com>2012-10-17 17:33:20 +0100
commit1e4fd7f4a76ea33d270912bbb9a4bf76cbd9d2a9 (patch)
tree7d6a1598e32cb27d3864cd219ee5fc9bedaf88d1
parentefaa7c1e2e3aca7136e601dffe9fb246519356a1 (diff)
parentd21d9b9dd10a1379ecb686e339992d7790e4bd61 (diff)
Merge remote-tracking branch 'openaustralia_github/fix_count_inconsistencies' into develop
-rw-r--r--app/controllers/general_controller.rb2
-rw-r--r--app/models/info_request.rb2
-rw-r--r--app/models/public_body.rb6
-rw-r--r--app/views/general/frontpage.rhtml6
4 files changed, 12 insertions, 4 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 21a318938..3fdfb4b0b 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -29,7 +29,7 @@ class GeneralController < ApplicationController
PublicBody.with_locale(@locale) do
if body_short_names.empty?
# This is too slow
- @popular_bodies = PublicBody.find(:all,
+ @popular_bodies = PublicBody.visible.find(:all,
:order => "info_requests_count desc",
:limit => 32,
:conditions => conditions,
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index d8c84fa9e..74a67b9d9 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -51,6 +51,8 @@ class InfoRequest < ActiveRecord::Base
has_tag_string
+ named_scope :visible, :conditions => {:prominence => "normal"}
+
# user described state (also update in info_request_event, admin_request/edit.rhtml)
validate :must_be_valid_state
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index c70aff9b9..c3bc060a4 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -42,6 +42,12 @@ class PublicBody < ActiveRecord::Base
has_tag_string
before_save :set_api_key, :set_default_publication_scheme
+ # Every public body except for the internal admin one is visible
+ named_scope :visible, lambda {
+ {
+ :conditions => "public_bodies.id <> #{PublicBody.internal_admin_body.id}"
+ }
+ }
translates :name, :short_name, :request_email, :url_name, :notes, :first_letter, :publication_scheme
diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml
index e2d74a5e2..7f25cdd14 100644
--- a/app/views/general/frontpage.rhtml
+++ b/app/views/general/frontpage.rhtml
@@ -15,7 +15,7 @@
<%= _("Search over<br/>
<strong>{{number_of_requests}} requests</strong> <span>and</span><br/>
<strong>{{number_of_authorities}} authorities</strong>",
- :number_of_requests => InfoRequest.count, :number_of_authorities => PublicBody.count) %>
+ :number_of_requests => InfoRequest.visible.count, :number_of_authorities => PublicBody.visible.count) %>
</h2>
<% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %>
<div>
@@ -36,7 +36,7 @@
<div id="examples_0">
<h3><%= _("Who can I request information from?") %></h3>
<%= _("{{site_name}} covers requests to {{number_of_authorities}} authorities, including:",
- :site_name => site_name, :number_of_authorities => PublicBody.count) %>
+ :site_name => site_name, :number_of_authorities => PublicBody.visible.count) %>
<ul>
<% for popular_body in @popular_bodies %>
<li><%=public_body_link(popular_body)%>
@@ -59,7 +59,7 @@
<% end %>
</h3>
<%= _("{{site_name}} users have made {{number_of_requests}} requests, including:",
- :site_name => site_name, :number_of_requests => InfoRequest.count) %>
+ :site_name => site_name, :number_of_requests => InfoRequest.visible.count) %>
<ul>
<% for event in @request_events %>
<li>