aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ability.rb5
-rw-r--r--lib/configuration.rb4
-rw-r--r--lib/cookie_store_with_line_break_fix.rb19
-rw-r--r--lib/mail_handler/backends/mail_backend.rb3
-rw-r--r--lib/mail_handler/backends/tmail_backend.rb10
-rw-r--r--lib/make_html_4_compliant.rb8
-rw-r--r--lib/tasks/gettext.rake15
-rw-r--r--lib/tasks/translation.rake6
8 files changed, 46 insertions, 24 deletions
diff --git a/lib/ability.rb b/lib/ability.rb
new file mode 100644
index 000000000..2865ccb1c
--- /dev/null
+++ b/lib/ability.rb
@@ -0,0 +1,5 @@
+module Ability
+ def self.can_update_request_state?(user, request)
+ (user && request.is_old_unclassified?) || request.is_owning_user?(user)
+ end
+end \ No newline at end of file
diff --git a/lib/configuration.rb b/lib/configuration.rb
index 11fe1c56e..4a0e0339b 100644
--- a/lib/configuration.rb
+++ b/lib/configuration.rb
@@ -4,9 +4,7 @@
module Configuration
DEFAULTS = {
- :ADMIN_BASE_URL => '',
:ADMIN_PASSWORD => '',
- :ADMIN_PUBLIC_URL => '',
:ADMIN_USERNAME => '',
:AVAILABLE_LOCALES => '',
:BLACKHOLE_PREFIX => 'do-not-reply-to-this-address',
@@ -16,10 +14,12 @@ module Configuration
:COOKIE_STORE_SESSION_SECRET => 'this default is insecure as code is open source, please override for live sites in config/general; this will do for local development',
:DEBUG_RECORD_MEMORY => false,
:DEFAULT_LOCALE => '',
+ :DISABLE_EMERGENCY_USER => false,
:DOMAIN => 'localhost:3000',
:EXCEPTION_NOTIFICATIONS_FROM => '',
:EXCEPTION_NOTIFICATIONS_TO => '',
:FORCE_REGISTRATION_ON_NEW_REQUEST => false,
+ :FORCE_SSL => true,
:FORWARD_NONBOUNCE_RESPONSES_TO => 'user-support@localhost',
:FRONTPAGE_PUBLICBODY_EXAMPLES => '',
:GA_CODE => '',
diff --git a/lib/cookie_store_with_line_break_fix.rb b/lib/cookie_store_with_line_break_fix.rb
new file mode 100644
index 000000000..dc623fbd0
--- /dev/null
+++ b/lib/cookie_store_with_line_break_fix.rb
@@ -0,0 +1,19 @@
+# See https://makandracards.com/makandra/9443-rails-2-s-cookiestore-produces-invalid-cookie-data-causing-tests-to-break
+
+# Should be able to remove this when we upgrade to Rails 3
+
+module ActionController
+ module Session
+ CookieStore.class_eval do
+
+ def call_with_line_break_fix(*args)
+ status, headers, body = call_without_line_break_fix(*args)
+ headers['Set-Cookie'].gsub! "\n\n", "\n" if headers['Set-Cookie'].present?
+ [ status, headers, body ]
+ end
+
+ alias_method_chain :call, :line_break_fix
+
+ end
+ end
+end \ No newline at end of file
diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb
index b75e6ed63..0a12ab3bb 100644
--- a/lib/mail_handler/backends/mail_backend.rb
+++ b/lib/mail_handler/backends/mail_backend.rb
@@ -8,8 +8,7 @@ module MailHandler
'Mail'
end
- # Note that the decode flag is not yet used
- def mail_from_raw_email(data, decode=true)
+ def mail_from_raw_email(data)
Mail.new(data)
end
diff --git a/lib/mail_handler/backends/tmail_backend.rb b/lib/mail_handler/backends/tmail_backend.rb
index 02124cdb1..1e241f261 100644
--- a/lib/mail_handler/backends/tmail_backend.rb
+++ b/lib/mail_handler/backends/tmail_backend.rb
@@ -8,14 +8,12 @@ module MailHandler
# Turn raw data into a structured TMail::Mail object
# Documentation at http://i.loveruby.net/en/projects/tmail/doc/
- def mail_from_raw_email(data, decode=true)
+ def mail_from_raw_email(data)
# Hack round bug in TMail's MIME decoding.
# Report of TMail bug:
# http://rubyforge.org/tracker/index.php?func=detail&aid=21810&group_id=4512&atid=17370
copy_of_raw_data = data.gsub(/; boundary=\s+"/im,'; boundary="')
- mail = TMail::Mail.parse(copy_of_raw_data)
- mail.base64_decode if decode
- mail
+ TMail::Mail.parse(copy_of_raw_data)
end
# Extracts all attachments from the given TNEF file as a TMail::Mail object
@@ -105,12 +103,12 @@ module MailHandler
if part.content_type == 'message/rfc822'
# An email attached as text
# e.g. http://www.whatdotheyknow.com/request/64/response/102
- part.rfc822_attachment = mail_from_raw_email(part.body, decode=false)
+ part.rfc822_attachment = mail_from_raw_email(part.body)
elsif part.content_type == 'application/vnd.ms-outlook' || part_filename && AlaveteliFileTypes.filename_to_mimetype(part_filename) == 'application/vnd.ms-outlook'
# An email attached as an Outlook file
# e.g. http://www.whatdotheyknow.com/request/chinese_names_for_british_politi
msg = Mapi::Msg.open(StringIO.new(part.body))
- part.rfc822_attachment = mail_from_raw_email(msg.to_mime.to_s, decode=false)
+ part.rfc822_attachment = mail_from_raw_email(msg.to_mime.to_s)
elsif part.content_type == 'application/ms-tnef'
# A set of attachments in a TNEF file
part.rfc822_attachment = mail_from_tnef(part.body)
diff --git a/lib/make_html_4_compliant.rb b/lib/make_html_4_compliant.rb
deleted file mode 100644
index 8926d5873..000000000
--- a/lib/make_html_4_compliant.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# Monkeypatch! Output HTML 4.0 compliant code, using method described in this
-# ticket: http://dev.rubyonrails.org/ticket/6009
-
-ActionView::Helpers::TagHelper.module_eval do
- def tag(name, options = nil, open = false, escape = true)
- "<#{name}#{tag_options(options, escape) if options}#{open ? ">" : ">"}".html_safe
- end
-end
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake
index 787b4029f..c73c2584e 100644
--- a/lib/tasks/gettext.rake
+++ b/lib/tasks/gettext.rake
@@ -4,6 +4,15 @@ Dir["#{Gem.searcher.find('gettext_i18n_rails').full_gem_path}/lib/tasks/**/*.rak
namespace :gettext do
+ desc 'Rewrite .po files into a consistent msgmerge format'
+ task :clean do
+ load_gettext
+
+ Dir.glob("locale/*/app.po") do |po_file|
+ GetText::msgmerge(po_file, po_file, 'alaveteli', :msgmerge => [:sort_output, :no_location, :no_wrap])
+ end
+ end
+
desc "Update pot file only, without fuzzy guesses (these are done by Transifex)"
task :findpot => :environment do
load_gettext
@@ -17,12 +26,12 @@ namespace :gettext do
#merge tmp.pot and existing pot
FileUtils.mkdir_p('locale')
- GetText::msgmerge("locale/app.pot", temp_pot, "alaveteli", :po_root => 'locale', :msgmerge=>[ :no_wrap, :sort_output ])
+ GetText::msgmerge("locale/app.pot", temp_pot, "alaveteli", :po_root => 'locale', :msgmerge=>[ :no_wrap, :sort_output ])
Dir.glob("locale/*/app.po") do |po_file|
- GetText::msgmerge(po_file, temp_pot, "alaveteli", :po_root => 'locale', :msgmerge=>[ :no_wrap, :sort_output ])
+ GetText::msgmerge(po_file, temp_pot, "alaveteli", :po_root => 'locale', :msgmerge=>[ :no_wrap, :sort_output ])
end
File.delete(temp_pot)
- end
+ end
def files_to_translate
Dir.glob("{app,lib,config,locale}/**/*.{rb,erb,haml,rhtml}")
diff --git a/lib/tasks/translation.rake b/lib/tasks/translation.rake
index 273c12bfa..ff07fc6f6 100644
--- a/lib/tasks/translation.rake
+++ b/lib/tasks/translation.rake
@@ -4,7 +4,7 @@ namespace :translation do
include Usage
def write_email(email, email_description, output_file)
- mail_object = MailHandler.mail_from_raw_email(email.to_s, decode=false)
+ mail_object = MailHandler.mail_from_raw_email(email.to_s)
output_file.write("\n")
output_file.write("Description of email: #{email_description}\n")
output_file.write("Subject line: #{mail_object.subject}\n")
@@ -49,7 +49,7 @@ namespace :translation do
write_email(followup_email, 'Follow up', output_file)
# contact mailer
- contact_email = ContactMailer.create_message(info_request.user_name,
+ contact_email = ContactMailer.create_to_admin_message(info_request.user_name,
info_request.user.email,
'A test message',
'Hello!',
@@ -86,7 +86,7 @@ namespace :translation do
'fixtures',
'files',
'incoming-request-plain.email'))
- response_mail = MailHandler.mail_from_raw_email(content, decode=false)
+ response_mail = MailHandler.mail_from_raw_email(content)
response_mail.from = "authority@example.com"
stopped_responses_email = RequestMailer.create_stopped_responses(info_request,