aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/general_controller.rb6
-rw-r--r--app/models/application_mailer.rb123
-rw-r--r--app/models/public_body.rb14
-rw-r--r--app/models/request_mailer.rb4
-rw-r--r--app/models/track_thing.rb18
-rw-r--r--app/views/contact_mailer/user_message.rhtml5
-rw-r--r--app/views/general/_advanced_search_tips.rhtml2
-rw-r--r--app/views/general/_frontpage_search_examples.es.rhtml1
-rw-r--r--app/views/general/_frontpage_search_examples.rhtml1
-rw-r--r--app/views/general/frontpage.rhtml24
-rw-r--r--app/views/help/contact.rhtml20
-rw-r--r--app/views/public_body/list.rhtml6
-rw-r--r--app/views/public_body/show.rhtml6
-rw-r--r--app/views/request/_summary_suggestion.rhtml5
-rw-r--r--app/views/request/new.rhtml7
-rw-r--r--app/views/request/upload_response.rhtml2
16 files changed, 194 insertions, 50 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 9e47af22a..03b988505 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -32,8 +32,7 @@ class GeneralController < ApplicationController
if body_short_names.empty?
# This is too slow
@popular_bodies = PublicBody.find(:all,
- :select => "public_bodies.*, (select count(*) from info_requests where info_requests.public_body_id = public_bodies.id) as c",
- :order => "c desc",
+ :order => "info_requests_count desc",
:limit => 32,
:conditions => conditions,
:joins => :translations
@@ -56,10 +55,13 @@ class GeneralController < ApplicationController
# If there are not yet enough successful requests, fill out the list with
# other requests
if @request_events.count < max_count
+ @request_events_all_successful = false
query = 'variety:sent'
xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count-@request_events.count)
more_events = xapian_object.results.map { |r| r[:model] }
@request_events += more_events
+ else
+ @request_events_all_successful = true
end
rescue
@request_events = []
diff --git a/app/models/application_mailer.rb b/app/models/application_mailer.rb
index 3a11733a8..add05ffdb 100644
--- a/app/models/application_mailer.rb
+++ b/app/models/application_mailer.rb
@@ -5,7 +5,7 @@
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
# $Id: application_mailer.rb,v 1.8 2009-02-09 10:37:12 francis Exp $
-
+require 'action_mailer/version'
class ApplicationMailer < ActionMailer::Base
# Include all the functions views get, as emails call similar things.
helper :application
@@ -26,5 +26,126 @@ class ApplicationMailer < ActionMailer::Base
# Site-wide access to configuration settings
include ConfigHelper
+
+ # Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer
+ # will be initialized according to the named method. If not, the mailer will
+ # remain uninitialized (useful when you only need to invoke the "receive"
+ # method, for instance).
+ def initialize(method_name=nil, *parameters) #:nodoc:
+ create!(method_name, *parameters) if method_name
+ end
+
+ # For each multipart template (e.g. "the_template_file.text.html.erb") available,
+ # add the one from the view path with the highest priority as a part to the mail
+ def render_multipart_templates
+ added_content_types = {}
+ self.view_paths.each do |view_path|
+ Dir.glob("#{view_path}/#{mailer_name}/#{@template}.*").each do |path|
+ template = view_path["#{mailer_name}/#{File.basename(path)}"]
+
+ # Skip unless template has a multipart format
+ next unless template && template.multipart?
+ next if added_content_types[template.content_type] == true
+ @parts << Part.new(
+ :content_type => template.content_type,
+ :disposition => "inline",
+ :charset => charset,
+ :body => render_message(template, @body)
+ )
+ added_content_types[template.content_type] = true
+ end
+ end
+ end
+
+ # Look for the current template in each element of view_paths in order,
+ # return the first
+ def find_template
+ self.view_paths.each do |view_path|
+ if template = view_path["#{mailer_name}/#{@template}"]
+ return template
+ end
+ end
+ return nil
+ end
+
+ if ActionMailer::VERSION::MAJOR == 2
+
+ # This method is a customised version of ActionMailer::Base.create!
+ # modified to allow templates to be selected correctly for multipart
+ # mails when themes have added to the view_paths. The problem from our
+ # point of view with ActionMailer::Base is that it sets template_root to
+ # the first element of the view_paths array and then uses only that (directly
+ # and via template_path, which is created from it) in the create! method when
+ # looking for templates. Our modified version looks for templates in the view_paths
+ # in order.
+ # Changed lines marked with ***
+
+ # Initialize the mailer via the given +method_name+. The body will be
+ # rendered and a new TMail::Mail object created.
+ def create!(method_name, *parameters) #:nodoc:
+ initialize_defaults(method_name)
+ __send__(method_name, *parameters)
+
+ # If an explicit, textual body has not been set, we check assumptions.
+ unless String === @body
+ # First, we look to see if there are any likely templates that match,
+ # which include the content-type in their file name (i.e.,
+ # "the_template_file.text.html.erb", etc.). Only do this if parts
+ # have not already been specified manually.
+ if @parts.empty?
+ # *** render_multipart_templates replaces the following code
+ # Dir.glob("#{template_path}/#{@template}.*").each do |path|
+ # template = template_root["#{mailer_name}/#{File.basename(path)}"]
+ #
+ # # Skip unless template has a multipart format
+ # next unless template && template.multipart?
+ #
+ # @parts << Part.new(
+ # :content_type => template.content_type,
+ # :disposition => "inline",
+ # :charset => charset,
+ # :body => render_message(template, @body)
+ # )
+ # end
+ render_multipart_templates
+
+ unless @parts.empty?
+ @content_type = "multipart/alternative" if @content_type !~ /^multipart/
+ @parts = sort_parts(@parts, @implicit_parts_order)
+ end
+ end
+
+ # Then, if there were such templates, we check to see if we ought to
+ # also render a "normal" template (without the content type). If a
+ # normal template exists (or if there were no implicit parts) we render
+ # it.
+ template_exists = @parts.empty?
+
+ # *** find_template replaces template_root call
+ # template_exists ||= template_root["#{mailer_name}/#{@template}"]
+ template_exists ||= find_template
+
+ @body = render_message(@template, @body) if template_exists
+
+ # Finally, if there are other message parts and a textual body exists,
+ # we shift it onto the front of the parts and set the body to nil (so
+ # that create_mail doesn't try to render it in addition to the parts).
+ if !@parts.empty? && String === @body
+ @parts.unshift ActionMailer::Part.new(:charset => charset, :body => @body)
+ @body = nil
+ end
+ end
+
+ # If this is a multipart e-mail add the mime_version if it is not
+ # already set.
+ @mime_version ||= "1.0" if !@parts.empty?
+
+ # build the mail object itself
+ @mail = create_mail
+ end
+ else
+ raise "ApplicationMailer.create! is obsolete - find another way to ensure that themes can override mail templates for multipart mails"
+ end
+
end
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index e9a90bce3..d212c371f 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -509,6 +509,20 @@ class PublicBody < ActiveRecord::Base
return self.request_email_domain
end
+ # Returns nil if configuration variable not set
+ def override_request_email
+ e = MySociety::Config.get("OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS", "")
+ e if e != ""
+ end
+
+ def request_email
+ if override_request_email
+ override_request_email
+ else
+ read_attribute(:request_email)
+ end
+ end
+
# Domain name of the request email
def request_email_domain
return PublicBody.extract_domain_from_email(self.request_email)
diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb
index 4316a9be9..3fc6b0471 100644
--- a/app/models/request_mailer.rb
+++ b/app/models/request_mailer.rb
@@ -50,7 +50,7 @@ class RequestMailer < ApplicationMailer
headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # we don't care about bounces, likely from spammers
'Auto-Submitted' => 'auto-replied' # http://tools.ietf.org/html/rfc3834
@recipients = email.from_addrs[0].to_s
- @subject = "Your response to an FOI request was not delivered"
+ @subject = _("Your response to an FOI request was not delivered")
attachment :content_type => 'message/rfc822', :body => raw_email_data,
:filename => "original.eml", :transfer_encoding => '7bit', :content_disposition => 'inline'
@body = {
@@ -154,7 +154,7 @@ class RequestMailer < ApplicationMailer
'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834
'X-Auto-Response-Suppress' => 'OOF'
@recipients = info_request.user.name_and_email
- @subject = "Someone has updated the status of your request"
+ @subject = _("Someone has updated the status of your request")
url = main_url(request_url(info_request))
@body = {:info_request => info_request, :url => url}
end
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index 9a553b382..63f356168 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -51,15 +51,15 @@ class TrackThing < ActiveRecord::Base
def TrackThing.track_type_description(track_type)
if track_type == 'request_updates'
- "Individual requests"
+ _("Individual requests")
elsif track_type == 'all_new_requests' || track_type == "all_successful_requests"
- "Many requests"
+ _("Many requests")
elsif track_type == 'public_body_updates'
- "Public authorities"
+ _("Public authorities")
elsif track_type == 'user_updates'
- "People"
+ _("People")
elsif track_type == 'search_query'
- "Search queries"
+ _("Search queries")
else
raise "internal error " + track_type
end
@@ -195,7 +195,7 @@ class TrackThing < ActiveRecord::Base
if self.track_type == 'request_updates'
@params = {
# Website
- :list_description => _("'{{link_to_request}}', a request", :link_to_request => "<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
+ :list_description => _("'{{link_to_request}}', a request", :link_to_request => "<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
:verb_on_page => _("Follow this request"),
:verb_on_page_already => _("You are already following this request"),
# Email
@@ -246,7 +246,7 @@ class TrackThing < ActiveRecord::Base
elsif self.track_type == 'public_body_updates'
@params = {
# Website
- :list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => "<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
+ :list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => "<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
:verb_on_page => _("Follow requests to {{public_body_name}}",:public_body_name=>CGI.escapeHTML(self.public_body.name)),
:verb_on_page_already => _("You are already following requests to {{public_body_name}}", :public_body_name=>CGI.escapeHTML(self.public_body.name)),
# Email
@@ -262,7 +262,7 @@ class TrackThing < ActiveRecord::Base
elsif self.track_type == 'user_updates'
@params = {
# Website
- :list_description => _("'{{link_to_user}}', a person", :link_to_user => "<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
+ :list_description => _("'{{link_to_user}}', a person", :link_to_user => "<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
:verb_on_page => _("Follow this person"),
:verb_on_page_already => _("You are already following this person"),
# Email
@@ -278,7 +278,7 @@ class TrackThing < ActiveRecord::Base
elsif self.track_type == 'search_query'
@params = {
# Website
- :list_description => "<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest/advanced\">" + self.track_query_description + "</a>", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
+ :list_description => "<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest/advanced\">" + self.track_query_description + "</a>", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how
:verb_on_page => _("Follow things matching this search"),
:verb_on_page_already => _("You are already following things matching this search"),
# Email
diff --git a/app/views/contact_mailer/user_message.rhtml b/app/views/contact_mailer/user_message.rhtml
index fe1f47518..b1d6e81ae 100644
--- a/app/views/contact_mailer/user_message.rhtml
+++ b/app/views/contact_mailer/user_message.rhtml
@@ -1,7 +1,8 @@
---------------------------------------------------------------------
<%= _('{{user_name}} has used {{site_name}} to send you the message below.', :user_name=>@from_user.name, :site_name=>site_name) %>
-<%= _('Your details have not been given to anyone, unless you choose to reply to this
-message, which will then go directly to the person who wrote the message.')%>
+<%= _('Your details, including your email address, have not been given to anyone.') %>
+<%= _('If you reply to this message it will go directly to {{user_name}}, who will
+learn your email address. Only reply if that is okay.', :user_name => @from_user.name) %>
---------------------------------------------------------------------
<%= @message.strip %>
diff --git a/app/views/general/_advanced_search_tips.rhtml b/app/views/general/_advanced_search_tips.rhtml
index 520cce89b..914abc1af 100644
--- a/app/views/general/_advanced_search_tips.rhtml
+++ b/app/views/general/_advanced_search_tips.rhtml
@@ -13,7 +13,7 @@
<li><%= _('<strong><code>request:</code></strong> to restrict to a specific request, typing the title as in the URL.')%>
<li><%= _('<strong><code>filetype:pdf</code></strong> to find all responses with PDF attachments. Or try these: <code>{{list_of_file_extensions}}</code>', :list_of_file_extensions => IncomingMessage.get_all_file_extensions)%></li>
<li><%= _('Type <strong><code>01/01/2008..14/01/2008</code></strong> to only show things that happened in the first two weeks of January.')%></li>
- <li><%= _('<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags,
+ <li><%= _('<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags,
and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags
can be present, you have to put <code>AND</code> explicitly if you only want results them all present.')%></li>
<li><%= _('Read about <a href="{{advanced_search_url}}">advanced search operators</a>, such as proximity and wildcards.', :advanced_search_url => "http://www.xapian.org/docs/queryparser.html") %></li>
diff --git a/app/views/general/_frontpage_search_examples.es.rhtml b/app/views/general/_frontpage_search_examples.es.rhtml
deleted file mode 100644
index 63c7c3c1e..000000000
--- a/app/views/general/_frontpage_search_examples.es.rhtml
+++ /dev/null
@@ -1 +0,0 @@
-por ejemplo <a href="/es/search/El%20Geraldine%20Quango">El Geraldine Quango</a>, <a href="/search/fancy%20dog">Fancy Dog</a>.
diff --git a/app/views/general/_frontpage_search_examples.rhtml b/app/views/general/_frontpage_search_examples.rhtml
deleted file mode 100644
index 359a132e2..000000000
--- a/app/views/general/_frontpage_search_examples.rhtml
+++ /dev/null
@@ -1 +0,0 @@
-for example <a href="/search/Geraldine%20Quango">Geraldine Quango</a> or <a href="/search/fancy%20dog">Fancy Dog</a>.
diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml
index 38133e7ab..e2d74a5e2 100644
--- a/app/views/general/frontpage.rhtml
+++ b/app/views/general/frontpage.rhtml
@@ -40,7 +40,7 @@
<ul>
<% for popular_body in @popular_bodies %>
<li><%=public_body_link(popular_body)%>
- <%= n_('%d request', '%d requests', popular_body.info_requests.count) % popular_body.info_requests.count %>
+ <%= n_('%d request', '%d requests', popular_body.info_requests_count) % popular_body.info_requests_count %>
</li>
<% end%>
</ul>
@@ -51,20 +51,32 @@
<% end %>
<div id="examples_1">
- <h3><%= _("What information has been released?") %></h3>
- <%= _("{{site_name}} users have made {{number_of_requests}} requests, including:",
+ <h3>
+ <% if @request_events_all_successful %>
+ <%= _("What information has been released?") %>
+ <% else %>
+ <%= _("What information has been requested?") %>
+ <% end %>
+ </h3>
+ <%= _("{{site_name}} users have made {{number_of_requests}} requests, including:",
:site_name => site_name, :number_of_requests => InfoRequest.count) %>
<ul>
<% for event in @request_events %>
<li>
<%= public_body_link(event.info_request.public_body) %> <%= _('answered a request about') %>
- <%=link_to h(event.info_request.title), request_url(event.info_request)%>
- <%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %>
+ <%=link_to h(event.info_request.title), request_url(event.info_request)%>
+ <%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %>
<p class="excerpt" onclick="document.location.href='<%=request_url(event.info_request)%>'"><%= excerpt(event.search_text_main(true), "", 200) %></p>
</li>
<% end %>
</ul>
- <p><strong><%=link_to _('More successful requests...'), request_list_successful_url %></strong></p>
+ <p><strong>
+ <% if @request_events_all_successful %>
+ <%=link_to _('More successful requests...'), request_list_successful_url %>
+ <% else %>
+ <%=link_to _('More requests...'), request_list_all_url %>
+ <% end %>
+ </strong></p>
</div>
</div>
diff --git a/app/views/help/contact.rhtml b/app/views/help/contact.rhtml
index dd49f7951..37df68f49 100644
--- a/app/views/help/contact.rhtml
+++ b/app/views/help/contact.rhtml
@@ -10,27 +10,18 @@
<h2>Contact an authority to get official information</h2>
<ul>
<li><a href="/new">Go here</a> to make a request, in public, for information
- from UK public authorities.</li>
+ from public authorities.</li>
<li>
Asking for private information about yourself?
- Please read our help page about
- <a href="/help/requesting#data_protection">data protection</a>.
+ Please read our
+ <a href="/help/requesting#data_protection">help page</a>.
</li>
</ul>
- <h2>Take up an issue with Government</h2>
-
- <ul>
- <li><a href="http://www.writetothem.com">Write to your MP,
- local councillor or other representative</a>.
- <li><a href="http://www.number10.gov.uk/">Number 10</a> is a good place to start if you would like to take an issue up with central government. </li>
- </ul>
-
-
<% end %>
- <h2>Contact the WhatDoTheyKnow team</h2>
+ <h2>Contact the <%= site_name %> team</h2>
<% if !flash[:notice] %>
<ul>
<li>
@@ -91,8 +82,7 @@
<p class="form_note">
We can only help you with <strong>technical problems</strong>, or questions
- about Freedom of Information. See the top of this page if you would like to
- contact the Government.
+ about Freedom of Information.
</P>
diff --git a/app/views/public_body/list.rhtml b/app/views/public_body/list.rhtml
index 8cb207bd4..a66a7f8fd 100644
--- a/app/views/public_body/list.rhtml
+++ b/app/views/public_body/list.rhtml
@@ -26,14 +26,14 @@
</ul>
<% end %>
<p>
- <%= _('<a href="%s">Are we missing a public authority?</a>.') % [help_requesting_path + '#missing_body'] %>
+ <%= _('<a href="%s">Are we missing a public authority?</a>') % [help_requesting_path + '#missing_body'] %>
</p>
<p>
<%= link_to _('List of all authorities (CSV)'), all_public_bodies_csv_url() %>
</p>
</div>
-<% @title = _("Public authorities - {{description}}", :description => @description) %>
+<% @title = @description.empty? ? _("Public authorities") : _("Public authorities - {{description}}", :description => @description) %>
<div id="left_column_flip">
<h1><%= _('Public authorities') %></h1>
@@ -44,7 +44,7 @@
</div>
<% end %>
-<h2 class="publicbody_results"><%= _('Found {{count}} public bodies {{description}}', :count=>@public_bodies.total_entries, :description=>@description) %></h2>
+<h2 class="publicbody_results"><%= _('Found {{count}} public authorities {{description}}', :count=>@public_bodies.total_entries, :description=>@description) %></h2>
<%= render :partial => 'body_listing', :locals => { :public_bodies => @public_bodies } %>
<%= will_paginate(@public_bodies) %><br/>
diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.rhtml
index 63bd5f7fc..b56556d5d 100644
--- a/app/views/public_body/show.rhtml
+++ b/app/views/public_body/show.rhtml
@@ -64,6 +64,12 @@
<% else %>
<%= _('For an unknown reason, it is not possible to make a request to this authority.')%>
<% end %>
+
+ <% if @public_body.override_request_email %>
+ <p>
+ <%= _("<strong>Note:</strong> Because we're testing, requests are being sent to {{email}} rather than to the actual authority.", :email => @public_body.override_request_email) %>
+ </p>
+ <% end %>
</div>
</div>
diff --git a/app/views/request/_summary_suggestion.rhtml b/app/views/request/_summary_suggestion.rhtml
new file mode 100644
index 000000000..a5da09cda
--- /dev/null
+++ b/app/views/request/_summary_suggestion.rhtml
@@ -0,0 +1,5 @@
+<% if @info_request.law_used == 'eir' %>
+ <%= _("'Pollution levels over time for the River Tyne'") %>
+<% else %>
+ <%= _("'Crime statistics by ward level for Wales'") %>
+<% end %>
diff --git a/app/views/request/new.rhtml b/app/views/request/new.rhtml
index 23212fc0b..2ef193c42 100644
--- a/app/views/request/new.rhtml
+++ b/app/views/request/new.rhtml
@@ -86,12 +86,7 @@
</p>
<div class="form_item_note">
(<%= _("a one line summary of the information you are requesting, \n\t\t\te.g.") %>
- <% if @info_request.law_used == 'eir' %>
- <%= _("'Pollution levels over time for the River Tyne'") %>
- <% else %>
- <%= _("'Crime statistics by ward level for Wales'") %>
- <% end %>
- )
+ <%= render :partial => "summary_suggestion" %>)
</div>
</div>
diff --git a/app/views/request/upload_response.rhtml b/app/views/request/upload_response.rhtml
index 697ff99aa..bc129426d 100644
--- a/app/views/request/upload_response.rhtml
+++ b/app/views/request/upload_response.rhtml
@@ -43,7 +43,7 @@
<p>
<%= hidden_field_tag 'submitted_upload_response', 1 %>
- <%= submit_tag "Upload FOI response" %>
+ <%= submit_tag _("Upload FOI response") %>
<%= _(' (<strong>patience</strong>, especially for large files, it may take a while!)')%>
</p>
<% end %>