Skip to content

Commit

Permalink
Allow calling code to specify context.
Browse files Browse the repository at this point in the history
A non-html means that strings will be marked as safe.

Requires mysociety/alaveteli@39d7c59
in the main alaveteli repo.
  • Loading branch information
crowbot committed Feb 9, 2015
1 parent 97f45b6 commit 6ea9f59
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/model_patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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 => 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 => title)
end
end
end
Expand Down

1 comment on commit 6ea9f59

@garethrees
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to the functionality, but shadowing title is a bit confusing. Maybe use subject_title?

Please sign in to comment.