aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-08-21 13:48:36 +0100
committerLouise Crow <louise.crow@gmail.com>2013-09-16 12:41:46 +0100
commitc4b2f6fee7cc38aff92909e5c763646a4d003bf4 (patch)
treefe70e07c18342c7aa194f5ece5366ef53dc103cb
parent1d8d08a9d6660732372d44ba4a8a733e630bb916 (diff)
Move a couple of complex conditionals to helper methods.
We're about to reuse them for the text view.
-rw-r--r--app/models/incoming_message.rb9
-rw-r--r--app/views/request/_incoming_correspondence.html.erb4
2 files changed, 11 insertions, 2 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 531982945..5ad645200 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -191,6 +191,15 @@ class IncomingMessage < ActiveRecord::Base
return mail_from
end
end
+
+ def specific_from_name?
+ !safe_mail_from.nil? && safe_mail_from.strip != info_request.public_body.name.strip
+ end
+
+ def from_public_body?
+ safe_mail_from.nil? || (mail_from_domain == info_request.public_body.request_email_domain)
+ end
+
def mail_from_domain
parse_raw_email!
super
diff --git a/app/views/request/_incoming_correspondence.html.erb b/app/views/request/_incoming_correspondence.html.erb
index f4550155b..1723f4d85 100644
--- a/app/views/request/_incoming_correspondence.html.erb
+++ b/app/views/request/_incoming_correspondence.html.erb
@@ -21,10 +21,10 @@
</p>
<% end %>
<h2>
- <% if incoming_message.safe_mail_from && incoming_message.safe_mail_from.strip != @info_request.public_body.name.strip %>
+ <% if incoming_message.specific_from_name? %>
<%= _("From:") %> <%= incoming_message.safe_mail_from %><br>
<% end %>
- <% if incoming_message.safe_mail_from.nil? || (incoming_message.mail_from_domain == @info_request.public_body.request_email_domain) %>
+ <% if incoming_message.from_public_body? %>
<%= @info_request.public_body.name %><br>
<% end %>
<br><%= simple_date(incoming_message.sent_at) %>