diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-08-21 14:10:37 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-09-16 12:42:19 +0100 |
commit | ef17ef91cd3a7bf109a6a9e9c845e1bea6ea9edf (patch) | |
tree | 0fdee6324f4e2393ebff5bcd99283878765b6ca9 | |
parent | d65804b7d8d2138b4570b26449321e1a9bb847fb (diff) |
Move display text generation to outgoing message.
-rw-r--r-- | app/models/outgoing_message.rb | 10 | ||||
-rw-r--r-- | app/views/request/_outgoing_correspondence.text.erb | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 5bd5898f9..07bb2a8e4 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -208,11 +208,11 @@ class OutgoingMessage < ActiveRecord::Base end # Returns text for indexing / text display - def get_text_for_indexing + def get_text_for_indexing(strip_salutation=true) text = self.body.strip # Remove salutation - text.sub!(/Dear .+,/, "") + text.sub!(/Dear .+,/, "") if strip_salutation # Remove email addresses from display/index etc. self.remove_privacy_sensitive_things!(text) @@ -232,6 +232,12 @@ class OutgoingMessage < ActiveRecord::Base return text.html_safe end + # Return body for display as text + def get_body_for_text_display + get_text_for_indexing(strip_salutation=false) + end + + def fully_destroy ActiveRecord::Base.transaction do info_request_event = InfoRequestEvent.find_by_outgoing_message_id(self.id) diff --git a/app/views/request/_outgoing_correspondence.text.erb b/app/views/request/_outgoing_correspondence.text.erb index c3f2b935d..fe2ad901c 100644 --- a/app/views/request/_outgoing_correspondence.text.erb +++ b/app/views/request/_outgoing_correspondence.text.erb @@ -1,6 +1,4 @@ <%= _('From:') %> <% if @info_request.user_name %><%= @info_request.user_name %><% else %><%= "[#{_('An anonymous user')}]"%><% end %> <%= _('To:') %> <%= @info_request.public_body.name %> <%= _('Date:') %> <%= simple_date(info_request_event.created_at) %> -<%- text = outgoing_message.body.strip - outgoing_message.remove_privacy_sensitive_things!(text) %> -<%= text %> +<%= outgoing_message.get_body_for_text_display %> |