From 0d533ce1d56e1ec1446774cc6fff52451a844f3f Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Sun, 9 Dec 2012 18:35:39 +1100
Subject: Switch to new method name
---
app/controllers/request_controller.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index c732a4b32..4fd914eb1 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -52,7 +52,7 @@ class RequestController < ApplicationController
medium_cache
end
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ PublicBody.with_locales(@locale) do
# Look up by old style numeric identifiers
if params[:url_title].match(/^[0-9]+$/)
@@ -804,7 +804,7 @@ class RequestController < ApplicationController
# FOI officers can upload a response
def upload_response
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ PublicBody.with_locales(@locale) do
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
@reason_params = {
@@ -861,7 +861,7 @@ class RequestController < ApplicationController
def download_entire_request
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ PublicBody.with_locales(@locale) do
info_request = InfoRequest.find_by_url_title!(params[:url_title])
if authenticated?(
:web => _("To download the zip file"),
--
cgit v1.2.3
From 64a93911ebae4eaa2a1bc2b9e09d1468d77aadb9 Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Sun, 9 Dec 2012 19:08:59 +1100
Subject: Remove interlock as it's not compatible with Rails 3 and is
unmaintained
---
app/controllers/request_controller.rb | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 4fd914eb1..aca806027 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -99,15 +99,13 @@ class RequestController < ApplicationController
# Sidebar stuff
# ... requests that have similar imporant terms
- behavior_cache :tag => ['similar', @info_request.id] do
- begin
- limit = 10
- @xapian_similar = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events,
- :limit => limit, :collapse_by_prefix => 'request_collapse')
- @xapian_similar_more = (@xapian_similar.matches_estimated > limit)
- rescue
- @xapian_similar = nil
- end
+ begin
+ limit = 10
+ @xapian_similar = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events,
+ :limit => limit, :collapse_by_prefix => 'request_collapse')
+ @xapian_similar_more = (@xapian_similar.matches_estimated > limit)
+ rescue
+ @xapian_similar = nil
end
# Track corresponding to this page
@@ -173,13 +171,10 @@ class RequestController < ApplicationController
query = make_query_from_params
@title = _("View and search requests")
sortby = "newest"
- @cache_tag = Digest::MD5.hexdigest(query + @page.to_s + I18n.locale.to_s)
- behavior_cache :tag => [@cache_tag] do
- xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse')
- @list_results = xapian_object.results.map { |r| r[:model] }
- @matches_estimated = xapian_object.matches_estimated
- @show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated
- end
+ xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse')
+ @list_results = xapian_object.results.map { |r| r[:model] }
+ @matches_estimated = xapian_object.matches_estimated
+ @show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated
@title = @title + " (page " + @page.to_s + ")" if (@page > 1)
@track_thing = TrackThing.create_track_for_search_query(query)
--
cgit v1.2.3
From 1f8bc6560b5240a7aa84ac8d6bdc47eea5d2d781 Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Mon, 10 Dec 2012 00:09:55 +1100
Subject: The with_locale has been removed in Globalize3
I think Globalize is supposed to pick up the locale from I18n anyway so I don't know if these are needed.
I think I still haven't done the right thing but it's time to move on.
---
app/controllers/request_controller.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index aca806027..c4e37f4c3 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -52,7 +52,7 @@ class RequestController < ApplicationController
medium_cache
end
@locale = self.locale_from_params()
- PublicBody.with_locales(@locale) do
+ I18n.with_locale(@locale) do
# Look up by old style numeric identifiers
if params[:url_title].match(/^[0-9]+$/)
@@ -799,7 +799,7 @@ class RequestController < ApplicationController
# FOI officers can upload a response
def upload_response
@locale = self.locale_from_params()
- PublicBody.with_locales(@locale) do
+ I18n.with_locale(@locale) do
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
@reason_params = {
@@ -856,7 +856,7 @@ class RequestController < ApplicationController
def download_entire_request
@locale = self.locale_from_params()
- PublicBody.with_locales(@locale) do
+ I18n.with_locale(@locale) do
info_request = InfoRequest.find_by_url_title!(params[:url_title])
if authenticated?(
:web => _("To download the zip file"),
--
cgit v1.2.3
From 2170a716b02baf65c1470ffc7d85056767a86364 Mon Sep 17 00:00:00 2001
From: Matthew Landauer
Date: Tue, 29 Jan 2013 17:32:32 +1100
Subject: render_for_text doesn't exist anymore. Replace with render :text
---
app/controllers/request_controller.rb | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 6106d68da..c18a97443 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -710,9 +710,8 @@ class RequestController < ApplicationController
if foi_fragment_cache_exists?(key_path)
logger.info("Reading cache for #{key_path}")
raise PermissionDenied.new("Directory listing not allowed") if File.directory?(key_path)
- cached = foi_fragment_cache_read(key_path)
- response.content_type = AlaveteliFileTypes.filename_to_mimetype(params[:file_name].join("/")) || 'application/octet-stream'
- render_for_text(cached)
+ render :text => foi_fragment_cache_read(key_path),
+ :content_type => (AlaveteliFileTypes.filename_to_mimetype(params[:file_name].join("/")) || 'application/octet-stream')
return
end
--
cgit v1.2.3
From ea03685aa9d09d7cd29e0ef875d3afa7758b29ea Mon Sep 17 00:00:00 2001
From: Matthew Landauer
Date: Thu, 31 Jan 2013 13:23:19 +1100
Subject: There's really no need to test the internals of Rails
---
app/controllers/request_controller.rb | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index c18a97443..500738b91 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -709,9 +709,13 @@ class RequestController < ApplicationController
key_path = foi_fragment_cache_path(key)
if foi_fragment_cache_exists?(key_path)
logger.info("Reading cache for #{key_path}")
- raise PermissionDenied.new("Directory listing not allowed") if File.directory?(key_path)
- render :text => foi_fragment_cache_read(key_path),
- :content_type => (AlaveteliFileTypes.filename_to_mimetype(params[:file_name].join("/")) || 'application/octet-stream')
+
+ if File.directory?(key_path)
+ render :text => "Directory listing not allowed", :status => 403
+ else
+ render :text => foi_fragment_cache_read(key_path),
+ :content_type => (AlaveteliFileTypes.filename_to_mimetype(params[:file_name].join("/")) || 'application/octet-stream')
+ end
return
end
--
cgit v1.2.3
From d05f4b605f21501e54d3576eae6f5f1af190ba18 Mon Sep 17 00:00:00 2001
From: Matthew Landauer
Date: Fri, 1 Feb 2013 16:59:31 +1100
Subject: Another hack to manually stitch together a fake email using tmail
---
app/controllers/request_controller.rb | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 500738b91..179c04e4e 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -853,7 +853,33 @@ class RequestController < ApplicationController
return
end
- mail = RequestMailer.create_fake_response(@info_request, @user, body, file_name, file_content)
+ # There is duplication of the email creation code in api_controller.rb
+ # TODO: Remove duplication
+ if MailHandler.backend == "TMail"
+ # Directly construct Tmail object using attachment_hashes
+ mail = TMail::Mail.new
+ mail.from = @user.name_and_email
+ mail.to = @info_request.incoming_name_and_email
+
+ b = TMail::Mail.new
+ b.body = body
+ b.set_content_type("text/plain")
+ b['Content-Disposition'] = "inline"
+ mail.parts << b
+
+ if !file_name.nil? && !file_content.nil?
+ content_type = AlaveteliFileTypes.filename_to_mimetype(file_name) || 'application/octet-stream'
+
+ attachment = TMail::Mail.new
+ attachment.body = Base64.encode64(file_content)
+ attachment.transfer_encoding = "base64"
+ attachment['Content-Type'] = "#{content_type}; name=\"#{file_name}\""
+ attachment['Content-Disposition'] = "attachment; filename=#{file_name}"
+ mail.parts << attachment
+ end
+ else
+ mail = RequestMailer.create_fake_response(@info_request, @user, body, file_name, file_content)
+ end
@info_request.receive(mail, mail.encoded, true)
flash[:notice] = _("Thank you for responding to this FOI request! Your response has been published below, and a link to your response has been emailed to ") + CGI.escapeHTML(@info_request.user.name) + "."
redirect_to request_url(@info_request)
--
cgit v1.2.3
From 7f93d7f1d486f55f6ebe9da37150d16b1a4fa634 Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Wed, 20 Feb 2013 11:58:48 +1100
Subject: Remove deprecated constants - #589
---
app/controllers/request_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 162060d9b..3bd032c3d 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -17,7 +17,7 @@ class RequestController < ApplicationController
@@custom_states_loaded = false
begin
- if ENV["RAILS_ENV"] != "test"
+ if !Rails.env.test?
require 'customstates'
include RequestControllerCustomStates
@@custom_states_loaded = true
--
cgit v1.2.3
From 919ea49682f899333a59f9f50fc5fe481a13d3ff Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Thu, 21 Feb 2013 17:51:38 +1100
Subject: Cast to a string so it's not saved to the DB as an object under Ruby
1.9.3
---
app/controllers/request_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 3bd032c3d..8786de9fc 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -345,7 +345,7 @@ class RequestController < ApplicationController
end
if !authenticated?(
- :web => _("To send your FOI request"),
+ :web => _("To send your FOI request").to_str,
:email => _("Then your FOI request to {{public_body_name}} will be sent.",:public_body_name=>@info_request.public_body.name),
:email_subject => _("Confirm your FOI request to ") + @info_request.public_body.name
)
--
cgit v1.2.3
From 3e4ef4da5374c1dd6d32ac9351decc9bb6851355 Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Mon, 25 Feb 2013 18:16:12 +1100
Subject: Update to new mail sending API
---
app/controllers/request_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 8786de9fc..daf290675 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -437,7 +437,7 @@ class RequestController < ApplicationController
:info_request_event_id => event.id)
# Don't give advice on what to do next, as it isn't their request
- RequestMailer.deliver_old_unclassified_updated(@info_request) if !@info_request.is_external?
+ RequestMailer.old_unclassified_updated(@info_request).deliver if !@info_request.is_external?
if session[:request_game]
flash[:notice] = _('Thank you for updating the status of the request \'{{info_request_title}}\'. There are some more requests below for you to classify.',:info_request_title=>CGI.escapeHTML(@info_request.title), :url=>CGI.escapeHTML(request_url(@info_request)))
redirect_to play_url
--
cgit v1.2.3
From 9d97fb84fe041a3479efae7c0c99c92abc07ad3d Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Mon, 25 Feb 2013 18:30:12 +1100
Subject: create_ is deprecated
---
app/controllers/request_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index daf290675..7895e05d5 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -878,7 +878,7 @@ class RequestController < ApplicationController
mail.parts << attachment
end
else
- mail = RequestMailer.create_fake_response(@info_request, @user, body, file_name, file_content)
+ mail = RequestMailer.fake_response(@info_request, @user, body, file_name, file_content)
end
@info_request.receive(mail, mail.encoded, true)
flash[:notice] = _("Thank you for responding to this FOI request! Your response has been published below, and a link to your response has been emailed to ") + CGI.escapeHTML(@info_request.user.name) + "."
--
cgit v1.2.3
From 90edee32bf6ad91522b3e1e772bca1e778a5ba7a Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Tue, 26 Feb 2013 13:39:43 +1100
Subject: file_name is passed as a string not an array
---
app/controllers/request_controller.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 7895e05d5..0c51d278f 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -714,7 +714,7 @@ class RequestController < ApplicationController
render :text => "Directory listing not allowed", :status => 403
else
render :text => foi_fragment_cache_read(key_path),
- :content_type => (AlaveteliFileTypes.filename_to_mimetype(params[:file_name].join("/")) || 'application/octet-stream')
+ :content_type => (AlaveteliFileTypes.filename_to_mimetype(params[:file_name]) || 'application/octet-stream')
end
return
end
@@ -742,7 +742,7 @@ class RequestController < ApplicationController
@incoming_message.binary_mask_stuff!(@attachment.body, @attachment.content_type)
# we don't use @attachment.content_type here, as we want same mime type when cached in cache_attachments above
- response.content_type = AlaveteliFileTypes.filename_to_mimetype(params[:file_name].join("/")) || 'application/octet-stream'
+ response.content_type = AlaveteliFileTypes.filename_to_mimetype(params[:file_name]) || 'application/octet-stream'
render :text => @attachment.body
end
@@ -792,7 +792,7 @@ class RequestController < ApplicationController
raise ActiveRecord::RecordNotFound.new(message)
end
@part_number = params[:part].to_i
- @filename = params[:file_name].join("/")
+ @filename = params[:file_name]
if html_conversion
@original_filename = @filename.gsub(/\.html$/, "")
else
--
cgit v1.2.3
From 835b51c1de0d49e652fe9c9a60f0974275de070c Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Wed, 27 Feb 2013 10:34:47 +1100
Subject: Rename ALL THE TEMPLATES!!1!!!one!!1!!
.rhtml is deprecated in favour of .erb in Rails 3
---
app/controllers/request_controller.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 0c51d278f..c8da8e845 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -893,7 +893,7 @@ class RequestController < ApplicationController
# by making the last work a wildcard, which is quite the same
query = params[:q]
@xapian_requests = perform_search_typeahead(query, InfoRequestEvent)
- render :partial => "request/search_ahead.rhtml"
+ render :partial => "request/search_ahead"
end
def download_entire_request
@@ -941,7 +941,7 @@ class RequestController < ApplicationController
end
if !done
@info_request_events = @info_request.info_request_events
- template = File.read(File.join(File.dirname(__FILE__), "..", "views", "request", "simple_correspondence.rhtml"))
+ template = File.read(File.join(File.dirname(__FILE__), "..", "views", "request", "simple_correspondence.html.erb"))
output = ERB.new(template).result(binding)
zipfile.get_output_stream("correspondence.txt") { |f|
f.puts(output)
--
cgit v1.2.3
From f07444d80961fcd3e7bb9555f5ed4a4e0b65b5db Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Wed, 27 Feb 2013 14:17:16 +1100
Subject: Remove Tmail and use the Mail gem under Ruby 1.8.7 as well
---
app/controllers/request_controller.rb | 29 ++---------------------------
1 file changed, 2 insertions(+), 27 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index c8da8e845..680833ae4 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -853,33 +853,8 @@ class RequestController < ApplicationController
return
end
- # There is duplication of the email creation code in api_controller.rb
- # TODO: Remove duplication
- if MailHandler.backend == "TMail"
- # Directly construct Tmail object using attachment_hashes
- mail = TMail::Mail.new
- mail.from = @user.name_and_email
- mail.to = @info_request.incoming_name_and_email
-
- b = TMail::Mail.new
- b.body = body
- b.set_content_type("text/plain")
- b['Content-Disposition'] = "inline"
- mail.parts << b
-
- if !file_name.nil? && !file_content.nil?
- content_type = AlaveteliFileTypes.filename_to_mimetype(file_name) || 'application/octet-stream'
-
- attachment = TMail::Mail.new
- attachment.body = Base64.encode64(file_content)
- attachment.transfer_encoding = "base64"
- attachment['Content-Type'] = "#{content_type}; name=\"#{file_name}\""
- attachment['Content-Disposition'] = "attachment; filename=#{file_name}"
- mail.parts << attachment
- end
- else
- mail = RequestMailer.fake_response(@info_request, @user, body, file_name, file_content)
- end
+ mail = RequestMailer.fake_response(@info_request, @user, body, file_name, file_content)
+
@info_request.receive(mail, mail.encoded, true)
flash[:notice] = _("Thank you for responding to this FOI request! Your response has been published below, and a link to your response has been emailed to ") + CGI.escapeHTML(@info_request.user.name) + "."
redirect_to request_url(@info_request)
--
cgit v1.2.3
From cbdff06aa95a7987b54c712dc6729e138f608eca Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Sun, 3 Mar 2013 14:52:30 +1100
Subject: Rename Configuration class to avoid conflict with
ActiveSupport::Configurable
---
app/controllers/request_controller.rb | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 680833ae4..a1c649888 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -28,7 +28,7 @@ class RequestController < ApplicationController
def select_authority
# Check whether we force the user to sign in right at the start, or we allow her
# to start filling the request anonymously
- if Configuration::force_registration_on_new_request && !authenticated?(
+ if AlaveteliConfiguration::force_registration_on_new_request && !authenticated?(
:web => _("To send your FOI request"),
:email => _("Then you'll be allowed to send FOI requests."),
:email_subject => _("Confirm your email address")
@@ -44,7 +44,7 @@ class RequestController < ApplicationController
end
def show
- if !Configuration::varnish_host.blank?
+ if !AlaveteliConfiguration::varnish_host.blank?
# If varnish is set up to accept PURGEs, then cache for a
# long time
long_cache
@@ -369,7 +369,7 @@ class RequestController < ApplicationController
replied by then.
If you write about this request (for example in a forum or a blog) please link to this page, and add an
annotation below telling people about your writing.
",:law_used_full=>@info_request.law_used_full,
- :late_number_of_days => Configuration::reply_late_after_days)
+ :late_number_of_days => AlaveteliConfiguration::reply_late_after_days)
redirect_to show_new_request_path(:url_title => @info_request.url_title)
end
@@ -458,7 +458,7 @@ class RequestController < ApplicationController
flash[:notice] = _("Thank you! Hope you don't have to wait much longer.
By law, you should have got a response promptly, and normally before the end of {{date_response_required_by}}.
",:date_response_required_by=>simple_date(@info_request.date_response_required_by))
redirect_to request_url(@info_request)
elsif calculated_status == 'waiting_response_very_overdue'
- flash[:notice] = _("Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.
", :very_late_number_of_days => Configuration::reply_very_late_after_days, :late_number_of_days => Configuration::reply_late_after_days)
+ flash[:notice] = _("Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.
", :very_late_number_of_days => AlaveteliConfiguration::reply_very_late_after_days, :late_number_of_days => AlaveteliConfiguration::reply_late_after_days)
redirect_to unhappy_url(@info_request)
elsif calculated_status == 'not_held'
flash[:notice] = _("Thank you! Here are some ideas on what to do next:
@@ -490,7 +490,7 @@ class RequestController < ApplicationController
elsif calculated_status == 'gone_postal'
redirect_to respond_to_last_url(@info_request) + "?gone_postal=1"
elsif calculated_status == 'internal_review'
- flash[:notice] = _("Thank you! Hopefully your wait isn't too long.
You should get a response within {{late_number_of_days}} days, or be told if it will take longer (details).
",:late_number_of_days => Configuration.reply_late_after_days, :review_url => unhappy_url(@info_request) + "#internal_review")
+ flash[:notice] = _("Thank you! Hopefully your wait isn't too long.
You should get a response within {{late_number_of_days}} days, or be told if it will take longer (details).
",:late_number_of_days => AlaveteliConfiguration.reply_late_after_days, :review_url => unhappy_url(@info_request) + "#internal_review")
redirect_to request_url(@info_request)
elsif calculated_status == 'error_message'
flash[:notice] = _("Thank you! We'll look into what happened and try and fix it up.
If the error was a delivery failure, and you can find an up to date FOI email address for the authority, please tell us using the form below.
")
@@ -896,10 +896,10 @@ class RequestController < ApplicationController
if !File.exists?(file_path)
FileUtils.mkdir_p(File.dirname(file_path))
Zip::ZipFile.open(file_path, Zip::ZipFile::CREATE) { |zipfile|
- convert_command = Configuration::html_to_pdf_command
+ convert_command = AlaveteliConfiguration::html_to_pdf_command
done = false
if !convert_command.blank? && File.exists?(convert_command)
- url = "http://#{Configuration::domain}#{request_url(@info_request)}?print_stylesheet=1"
+ url = "http://#{AlaveteliConfiguration::domain}#{request_url(@info_request)}?print_stylesheet=1"
tempfile = Tempfile.new('foihtml2pdf')
output = AlaveteliExternalCommand.run(convert_command, url, tempfile.path)
if !output.nil?
--
cgit v1.2.3
From ad62ab35b1086d5e3890e4b09fada3d0c6e407aa Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Mon, 4 Mar 2013 17:19:15 +1100
Subject: Rails 3.1 doesn't load the association from the id when creating a
new InfoRequest object
---
app/controllers/request_controller.rb | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index a1c649888..b4f20ff42 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -243,16 +243,16 @@ class RequestController < ApplicationController
# Read parameters in - first the public body (by URL name or id)
if params[:url_name]
if params[:url_name].match(/^[0-9]+$/)
- params[:info_request][:public_body_id] = params[:url_name]
+ params[:info_request][:public_body] = PublicBody.find(params[:url_name])
else
public_body = PublicBody.find_by_url_name_with_historic(params[:url_name])
raise ActiveRecord::RecordNotFound.new("None found") if public_body.nil? # XXX proper 404
- params[:info_request][:public_body_id] = public_body.id
+ params[:info_request][:public_body] = public_body
end
elsif params[:public_body_id]
- params[:info_request][:public_body_id] = params[:public_body_id]
+ params[:info_request][:public_body] = PublicBody.find(params[:public_body_id])
end
- if !params[:info_request][:public_body_id]
+ if !params[:info_request][:public_body]
# compulsory to have a body by here, or go to front page which is start of process
redirect_to frontpage_url
return
--
cgit v1.2.3
From 0d9bcbfc49d5352bd74f780d77792aa873e41596 Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Mon, 4 Mar 2013 17:43:27 +1100
Subject: Explicitly load association. Doesn't feel right but probably should
refactor all this anyway
---
app/controllers/request_controller.rb | 3 +++
1 file changed, 3 insertions(+)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index b4f20ff42..241010049 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -251,6 +251,9 @@ class RequestController < ApplicationController
end
elsif params[:public_body_id]
params[:info_request][:public_body] = PublicBody.find(params[:public_body_id])
+ # Explicitly load the association as this isn't done automatically in newer Rails versions
+ elsif params[:info_request][:public_body_id]
+ params[:info_request][:public_body] = PublicBody.find(params[:info_request][:public_body_id])
end
if !params[:info_request][:public_body]
# compulsory to have a body by here, or go to front page which is start of process
--
cgit v1.2.3
From d348cbf1de3d10818e4994c04f842c15bb333b99 Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Fri, 15 Mar 2013 15:18:09 +1100
Subject: Fix up some merge action from
f60ada47d4e7aabe0dce152109cb0d91865929da
---
app/controllers/request_controller.rb | 1 -
1 file changed, 1 deletion(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 33f18e737..e69147b0b 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -427,7 +427,6 @@ class RequestController < ApplicationController
# admin user (not because you also own the request).
if !info_request.is_actual_owning_user?(authenticated_user)
# Don't give advice on what to do next, as it isn't their request
- RequestMailer.deliver_old_unclassified_updated(@info_request) if !@info_request.is_external?
if session[:request_game]
flash[:notice] = _('Thank you for updating the status of the request \'{{info_request_title}}\'. There are some more requests below for you to classify.',:info_request_title=>CGI.escapeHTML(info_request.title), :url=>CGI.escapeHTML(request_path(info_request)))
redirect_to categorise_play_url
--
cgit v1.2.3
From 25a2d162261f727bf899520181255f60062410a8 Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Fri, 15 Mar 2013 15:21:07 +1100
Subject: Whoever said don't sweat the small stuff obviously never messed up a
merge and missed changing variable scope
---
app/controllers/request_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index e69147b0b..6012576bf 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -437,7 +437,7 @@ class RequestController < ApplicationController
return
end
- calculated_status = @info_request.calculate_status
+ calculated_status = info_request.calculate_status
# Display advice for requester on what to do next, as appropriate
flash[:notice] = case info_request.calculate_status
when 'waiting_response'
--
cgit v1.2.3
From 5fd3a2791d79993b250c6396114044c9e89748c7 Mon Sep 17 00:00:00 2001
From: Henare Degan
Date: Fri, 15 Mar 2013 16:35:11 +1100
Subject: Config name change missed in the merge
---
app/controllers/request_controller.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 6012576bf..1b1ac52c3 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -446,7 +446,7 @@ class RequestController < ApplicationController
when 'waiting_response_overdue'
_("Thank you! Hope you don't have to wait much longer.
By law, you should have got a response promptly, and normally before the end of {{date_response_required_by}}.
",:date_response_required_by=>simple_date(info_request.date_response_required_by))
when 'waiting_response_very_overdue'
- _("Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.
", :very_late_number_of_days => Configuration::reply_very_late_after_days, :late_number_of_days => Configuration::reply_late_after_days)
+ _("Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.
", :very_late_number_of_days => AlaveteliConfiguration::reply_very_late_after_days, :late_number_of_days => AlaveteliConfiguration::reply_late_after_days)
when 'not_held'
_("Thank you! Here are some ideas on what to do next:
@@ -472,7 +472,7 @@ class RequestController < ApplicationController
when 'gone_postal'
nil
when 'internal_review'
- _("Thank you! Hopefully your wait isn't too long.
You should get a response within {{late_number_of_days}} days, or be told if it will take longer (details).
",:late_number_of_days => Configuration.reply_late_after_days, :review_url => unhappy_url(info_request) + "#internal_review")
+ _("Thank you! Hopefully your wait isn't too long.
You should get a response within {{late_number_of_days}} days, or be told if it will take longer (details).
",:late_number_of_days => AlaveteliConfiguration.reply_late_after_days, :review_url => unhappy_url(info_request) + "#internal_review")
when 'error_message', 'requires_admin'
_("Thank you! We'll look into what happened and try and fix it up.")
when 'user_withdrawn'
--
cgit v1.2.3
From 885acdc9c6865ac9d8dc66450b952b808c96efd9 Mon Sep 17 00:00:00 2001
From: Matthew Landauer
Date: Tue, 19 Mar 2013 08:03:20 +1100
Subject: Stop pollution of params[:outgoing_message]
---
app/controllers/request_controller.rb | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 1b1ac52c3..ad1918005 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -564,10 +564,7 @@ class RequestController < ApplicationController
end
- params_outgoing_message = params[:outgoing_message]
- if params_outgoing_message.nil?
- params_outgoing_message = {}
- end
+ params_outgoing_message = params[:outgoing_message] ? params[:outgoing_message].clone : {}
params_outgoing_message.merge!({
:status => 'ready',
:message_type => 'followup',
--
cgit v1.2.3
From 44ec166b8691743e0ffbcc108eaf41ab0d2ef3cd Mon Sep 17 00:00:00 2001
From: Matthew Landauer
Date: Tue, 26 Mar 2013 09:47:06 +1100
Subject: Change email address in header of source code to hello@mysociety.org
---
app/controllers/request_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index ad1918005..ea84d3b10 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -2,7 +2,7 @@
# Show information about one particular request.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
require 'alaveteli_file_types'
require 'zip/zip'
--
cgit v1.2.3
From 68bcab4396a38bae45b5c16c4826dadee6e06b3e Mon Sep 17 00:00:00 2001
From: Mark Longair
Date: Tue, 16 Apr 2013 12:54:07 +0100
Subject: Add encoding specifications to two files that use UTF-8
Both of these files include multi-byte UTF-8 sequences,
so should have a 'magic comment' specifying the encoding.
---
app/controllers/request_controller.rb | 1 +
1 file changed, 1 insertion(+)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index ea84d3b10..fe212fb42 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -1,3 +1,4 @@
+# encoding: UTF-8
# app/controllers/request_controller.rb:
# Show information about one particular request.
#
--
cgit v1.2.3
From 97d5046613b474c49e97cd108b874ac0e0c3f4cf Mon Sep 17 00:00:00 2001
From: Mark Longair
Date: Thu, 16 May 2013 12:12:42 +0100
Subject: Move "require 'alaveteli_file_types'" into the initializer
---
app/controllers/request_controller.rb | 1 -
1 file changed, 1 deletion(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index a0f88096e..5b64fe9ae 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -5,7 +5,6 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
-require 'alaveteli_file_types'
require 'zip/zip'
require 'open-uri'
--
cgit v1.2.3
From 501b2b8672d294268b2eb112092e70ffc2728539 Mon Sep 17 00:00:00 2001
From: Mark Longair
Date: Fri, 24 May 2013 18:50:16 +0100
Subject: Check that display_filename matches URL part number or fallback
If the display_filename of the attachment found from the
URL part number doesn't match the passed in display_filename
then the email may have been reparsed, causing a reordering.
In that case, look to see if there is another attachment that
uniquely matches that filename, and, if so, return that other
attachment. If no matching uniquely matching filename is
found, redirect to the incoming message, rather than
returning a 404.
---
app/controllers/request_controller.rb | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 5b64fe9ae..96f62319e 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -736,6 +736,7 @@ class RequestController < ApplicationController
def get_attachment
get_attachment_internal(false)
+ return unless @attachment
# Prevent spam to magic request address. Note that the binary
# subsitution method used depends on the content type
@@ -755,6 +756,7 @@ class RequestController < ApplicationController
raise ActiveRecord::RecordNotFound.new("Attachment HTML not found.")
end
get_attachment_internal(true)
+ return unless @attachment
# images made during conversion (e.g. images in PDF files) are put in the cache directory, so
# the same cache code in cache_attachments above will display them.
@@ -801,8 +803,11 @@ class RequestController < ApplicationController
# check permissions
raise "internal error, pre-auth filter should have caught this" if !@info_request.user_can_view?(authenticated_user)
- @attachment = IncomingMessage.get_attachment_by_url_part_number(@incoming_message.get_attachments_for_display, @part_number)
- raise ActiveRecord::RecordNotFound.new("attachment not found part number " + @part_number.to_s + " incoming_message " + @incoming_message.id.to_s) if @attachment.nil?
+ @attachment = IncomingMessage.get_attachment_by_url_part_number_and_filename(@incoming_message.get_attachments_for_display, @part_number, @original_filename)
+ # If we can't find the right attachment, redirect to the incoming message:
+ unless @attachment
+ return redirect_to incoming_message_url(@incoming_message), :status => 303
+ end
# check filename in URL matches that in database (use a censor rule if you want to change a filename)
raise ActiveRecord::RecordNotFound.new("please use same filename as original file has, display: '" + @attachment.display_filename + "' old_display: '" + @attachment.old_display_filename + "' original: '" + @original_filename + "'") if @attachment.display_filename != @original_filename && @attachment.old_display_filename != @original_filename
--
cgit v1.2.3
From 011e55bd4acf4f3c9de91c5ed4c646e855f19c24 Mon Sep 17 00:00:00 2001
From: Mark Longair
Date: Fri, 24 May 2013 14:42:43 +0100
Subject: Only cache attachments that are returned with a 200 HTTP status code
Otherwise redirects will be cached, and since headers and the status
code aren't stored, a non-redirecting redirect page will be returned
in the future, but with 200. It's easiest to only cache the 200
responses.
---
app/controllers/request_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 96f62319e..b8ccdf926 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -721,7 +721,7 @@ class RequestController < ApplicationController
yield
- if params[:skip_cache].nil?
+ if params[:skip_cache].nil? && response.status == 200
# write it to the fileystem ourselves, so is just a plain file. (The
# various fragment cache functions using Ruby Marshall to write the file
# which adds a header, so isnt compatible with images that have been
--
cgit v1.2.3
From d9d9997a1d0f6d361097a8a4bdf1aa0fee24edaa Mon Sep 17 00:00:00 2001
From: Louise Crow
Date: Mon, 3 Jun 2013 16:41:14 +0100
Subject: Handle json requests for hidden info requests.
---
app/controllers/request_controller.rb | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index b8ccdf926..a455d1725 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -67,8 +67,7 @@ class RequestController < ApplicationController
# Test for whole request being hidden
if !@info_request.user_can_view?(authenticated_user)
- render :template => 'request/hidden', :status => 410 # gone
- return
+ return render_hidden
end
# Other parameters
@@ -126,8 +125,7 @@ class RequestController < ApplicationController
long_cache
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
if !@info_request.user_can_view?(authenticated_user)
- render :template => 'request/hidden', :status => 410 # gone
- return
+ return render_hidden
end
@columns = ['id', 'event_type', 'created_at', 'described_state', 'last_described_at', 'calculated_state' ]
end
@@ -146,8 +144,7 @@ class RequestController < ApplicationController
raise ActiveRecord::RecordNotFound.new("Request not found") if @info_request.nil?
if !@info_request.user_can_view?(authenticated_user)
- render :template => 'request/hidden', :status => 410 # gone
- return
+ return render_hidden
end
@xapian_object = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events,
:offset => (@page - 1) * @per_page, :limit => @per_page, :collapse_by_prefix => 'request_collapse')
@@ -587,8 +584,7 @@ class RequestController < ApplicationController
# Test for hidden requests
if !authenticated_user.nil? && !@info_request.user_can_view?(authenticated_user)
- render :template => 'request/hidden', :status => 410 # gone
- return
+ return render_hidden
end
# Check address is good
@@ -671,7 +667,7 @@ class RequestController < ApplicationController
raise ActiveRecord::RecordNotFound.new("Message not found") if incoming_message.nil?
if !incoming_message.info_request.user_can_view?(authenticated_user)
@info_request = incoming_message.info_request # used by view
- render :template => 'request/hidden', :status => 410 # gone
+ return render_hidden
end
# Is this a completely public request that we can cache attachments for
# to be served up without authentication?
@@ -711,7 +707,7 @@ class RequestController < ApplicationController
logger.info("Reading cache for #{key_path}")
if File.directory?(key_path)
- render :text => "Directory listing not allowed", :status => 403
+ render :text => "Directory listing not allowed", :status => 403
else
render :text => foi_fragment_cache_read(key_path),
:content_type => (AlaveteliFileTypes.filename_to_mimetype(params[:file_name]) || 'application/octet-stream')
@@ -882,8 +878,7 @@ class RequestController < ApplicationController
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
# Test for whole request being hidden or requester-only
if !@info_request.all_can_view?
- render :template => 'request/hidden', :status => 410 # gone
- return
+ return render_hidden
end
if authenticated?(
:web => _("To download the zip file"),
@@ -943,5 +938,17 @@ class RequestController < ApplicationController
end
end
end
+
+ private
+
+ def render_hidden
+ respond_to do |format|
+ response_code = 410 # gone
+ format.html{ render :template => 'request/hidden', :status => response_code }
+ format.any{ render :nothing => true, :status => response_code }
+ end
+ false
+ end
+
end
--
cgit v1.2.3