diff options
-rw-r--r-- | Gemfile | 1 | ||||
-rw-r--r-- | Gemfile.lock | 2 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 7 | ||||
-rw-r--r-- | app/views/request_mailer/requires_admin.rhtml | 2 | ||||
-rw-r--r-- | config/varnish-alaveteli.vcl | 5 | ||||
-rw-r--r-- | doc/INSTALL.md | 9 | ||||
-rw-r--r-- | lib/quiet_opener.rb | 22 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 3 |
8 files changed, 36 insertions, 15 deletions
@@ -17,6 +17,7 @@ gem 'json', '~> 1.5.1' gem 'mahoro' gem 'memcache-client', :require => 'memcache' gem 'locale', '>= 2.0.5' +gem 'net-http-local' gem 'net-purge' gem 'rack', '~> 1.1.0' gem 'rdoc', '~> 2.4.3' diff --git a/Gemfile.lock b/Gemfile.lock index 695baae02..f17e72d33 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,6 +30,7 @@ GEM locale (2.0.5) mahoro (0.3) memcache-client (1.8.5) + net-http-local (0.1.2) net-purge (0.1.0) pg (0.11.0) rack (1.1.0) @@ -79,6 +80,7 @@ DEPENDENCIES locale (>= 2.0.5) mahoro memcache-client + net-http-local net-purge pg rack (~> 1.1.0) diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index c208923f3..1b0bb48b9 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -47,15 +47,16 @@ class RequestMailer < ApplicationMailer # An FOI response is outside the scope of the system, and needs admin attention def requires_admin(info_request, set_by = nil) if !set_by.nil? - @from = set_by.name_and_email + user = set_by else - @from = info_request.user.name_and_email + user = info_request.user end + @from = user.name_and_email @recipients = contact_from_name_and_email @subject = _("FOI response requires admin ({{reason}}) - {{title}}", :reason => info_request.described_state, :title => info_request.title) url = main_url(request_url(info_request)) admin_url = request_admin_url(info_request) - @body = {:info_request => info_request, :url => url, :admin_url => admin_url } + @body = {:reported_by => user, :info_request => info_request, :url => url, :admin_url => admin_url } end # Tell the requester that a new response has arrived diff --git a/app/views/request_mailer/requires_admin.rhtml b/app/views/request_mailer/requires_admin.rhtml index acd37f405..06a798792 100644 --- a/app/views/request_mailer/requires_admin.rhtml +++ b/app/views/request_mailer/requires_admin.rhtml @@ -1,5 +1,5 @@ --------------------------------------------------------------------- -<%=@info_request.user.name%> <%= _('has reported an')%> <%=@info_request.law_used_short%> +<%=@reported_by.name%> <%= _('has reported an')%> <%=@info_request.law_used_short%> <%= _('response as needing administrator attention. Take a look, and reply to this email to let them know what you are going to do about it.')%> diff --git a/config/varnish-alaveteli.vcl b/config/varnish-alaveteli.vcl index 452a956da..77350a8c8 100644 --- a/config/varnish-alaveteli.vcl +++ b/config/varnish-alaveteli.vcl @@ -87,6 +87,11 @@ sub vcl_recv { if (!client.ip ~ purge) { error 405 "Not allowed."; } + + # For an explanation of the followng roundabout way of defining + # ban lists, see + # http://kristianlyng.wordpress.com/2010/07/28/smart-bans-with-varnish/ + # XXX in Varnish 2.x, the following would be # purge("obj.http.x-url ~ " req.url); ban("obj.http.x-url ~ " + req.url); diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 6ed29f677..ef354c5ce 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -365,6 +365,15 @@ further action. You should read the `CHANGES.md` document to see what's changed since your last deployment, paying special attention to anything in the "Updgrading" sections. +Any upgrade may include new translations strings, i.e. new or altered +messages to the user that need translating to your locale. You should +visit Transifex and try to get your translation up to 100% on each new +release. Failure to do so means that any new words added to the +Alaveteli source code will appear in your website in English by +default. If your translations didn't make it to the latest release, +you will need to download the updated `app.po` for your locale from +Transifex and save it in the `locales/` folder. + You should always run the script `scripts/rails-post-deploy` after each deployment. This runs any database migrations for you, plus various other things that can be automated for deployment. diff --git a/lib/quiet_opener.rb b/lib/quiet_opener.rb index a077ca323..2f78f76ad 100644 --- a/lib/quiet_opener.rb +++ b/lib/quiet_opener.rb @@ -5,7 +5,7 @@ def quietly_try_to_open(url) begin result = open(url).read.strip rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH - logger.warn("Unable to open third-party URL #{url}") + Rails.logger.warn("Unable to open third-party URL #{url}") result = "" end return result @@ -15,19 +15,21 @@ def quietly_try_to_purge(host, url) begin result = "" result_body = "" - Net::HTTP.start(host) {|http| - request = Net::HTTP::Purge.new(url) - response = http.request(request) - result = response.code - result_body = response.body - } + Net::HTTP.bind '127.0.0.1' do + Net::HTTP.start(host) {|http| + request = Net::HTTP::Purge.new(url) + response = http.request(request) + result = response.code + result_body = response.body + } + end rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH - logger.warn("Unable to reach host #{host}") + Rails.logger.warn("Unable to reach host #{host}") end if result == "200" - logger.info("Purged URL #{url} at #{host}: #{result}") + Rails.logger.info("Purged URL #{url} at #{host}: #{result}") else - logger.warn("Unable to purge URL #{url} at #{host}: status #{result}") + Rails.logger.warn("Unable to purge URL #{url} at #{host}: status #{result}") end return result end diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 28f56dcf6..99ab4cc71 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1877,7 +1877,7 @@ describe RequestController, "when reporting a request" do info_requests(:badger_request).set_described_state("successful") get :show, :url_title => title response.body.should_not include("This request has been reported") - response.body.should include("The site administrators have reviewed this request") + response.body.should =~ (/the site administrators.*have not hidden it/) end it "should send an email from the reporter to admins" do @@ -1889,6 +1889,7 @@ describe RequestController, "when reporting a request" do mail = deliveries[0] mail.subject.should =~ /attention_requested/ mail.from.should include(@user.email) + mail.body.should include(@user.name) end end |