From 3f3e3a4643d23713b9a7987932abf9e7b907f462 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 18 Nov 2014 16:32:16 +0000 Subject: [PATCH] Allow calling code to specify context. A non-html means that strings will be marked as safe. Requires https://github.com/mysociety/alaveteli/commit/39d7c598161b6b1577ef6d18de7d13e68fa5706f in the main alaveteli repo. --- lib/model_patches.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/model_patches.rb b/lib/model_patches.rb index 32b1b649..8ec9baee 100644 --- a/lib/model_patches.rb +++ b/lib/model_patches.rb @@ -21,12 +21,16 @@ def survey UserInfoRequestSentAlert._validate_callbacks[0].options[:in] << 'survey_1' InfoRequest.class_eval do - def email_subject_request - if (!self.is_batch_request_template?) && (self.public_body.url_name == 'general_register_office') + def email_subject_request(opts = {}) + html = opts.fetch(:html, true) + subject_title = html ? self.title : self.title.html_safe + if (!is_batch_request_template?) && (public_body.url_name == 'general_register_office') # without GQ in the subject, you just get an auto response - _('{{law_used_full}} request GQ - {{title}}',:law_used_full=>self.law_used_full,:title=>self.title.html_safe) + _('{{law_used_full}} request GQ - {{title}}', :law_used_full => law_used_full, + :title => subject_title) else - _('{{law_used_full}} request - {{title}}',:law_used_full=>self.law_used_full,:title=>self.title.html_safe) + _('{{law_used_full}} request - {{title}}', :law_used_full => law_used_full, + :title => subject_title) end end end