aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/incoming_message.rb2
-rw-r--r--app/models/outgoing_message.rb3
-rw-r--r--app/views/request/_incoming_correspondence.html.erb19
-rw-r--r--app/views/request/_outgoing_correspondence.html.erb27
-rw-r--r--app/views/request/_restricted_correspondence.html.erb18
5 files changed, 39 insertions, 30 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 96ecc7d53..85140398c 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -50,7 +50,7 @@ class IncomingMessage < ActiveRecord::Base
belongs_to :raw_email
- has_prominence(prominence_states = ['normal', 'hidden','requester_only'])
+ has_prominence
# See binary_mask_stuff function below. It just test for inclusion
# in this hash, not the value of the right hand side.
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index 07bb2a8e4..e89c11141 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -22,6 +22,7 @@
# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class OutgoingMessage < ActiveRecord::Base
+ extend MessageProminence
include Rails.application.routes.url_helpers
include LinkToHelper
self.default_url_options[:host] = AlaveteliConfiguration::domain
@@ -32,6 +33,8 @@ class OutgoingMessage < ActiveRecord::Base
strip_attributes!
+ has_prominence
+
belongs_to :info_request
validates_presence_of :info_request
diff --git a/app/views/request/_incoming_correspondence.html.erb b/app/views/request/_incoming_correspondence.html.erb
index 1723f4d85..cd601a8ef 100644
--- a/app/views/request/_incoming_correspondence.html.erb
+++ b/app/views/request/_incoming_correspondence.html.erb
@@ -2,24 +2,7 @@
<%- if not incoming_message.user_can_view?(@user) %>
<%= render :partial => 'request/hidden_correspondence', :locals => { :message => incoming_message }%>
<%- else %>
- <% if incoming_message.prominence == 'hidden' %>
- <p id="hidden_message">
- <%- if !incoming_message.prominence_reason.blank? %>
- <%= _('This message has prominence \'hidden\'. {{reason}} You can only see it because you are logged in as a super user.', :reason => incoming_message.prominence_reason) %>
- <%- else %>
- <%= _('This message has prominence \'hidden\'. You can only see it because you are logged in as a super user.') %>
- <%- end %>
- </p>
- <% end %>
- <% if incoming_message.prominence == 'requester_only' %>
- <p id="hidden_message">
- <%- if !incoming_message.prominence_reason.blank? %>
- <%= _('This message is hidden, so that only you, the requester, can see it. {{reason}}', :reason => incoming_message.prominence_reason) %>
- <%- else %>
- <%= _('This message is hidden, so that only you, the requester, can see it. Please <a href="{{url}}">contact us</a> if you are not sure why.', :url => help_requesting_path.html_safe) %>
- <%- end %>
- </p>
- <% end %>
+ <%= render :partial => 'request/restricted_correspondence', :locals => {:message => incoming_message } %>
<h2>
<% if incoming_message.specific_from_name? %>
<%= _("From:") %> <%= incoming_message.safe_mail_from %><br>
diff --git a/app/views/request/_outgoing_correspondence.html.erb b/app/views/request/_outgoing_correspondence.html.erb
index b43af0753..dced5c94c 100644
--- a/app/views/request/_outgoing_correspondence.html.erb
+++ b/app/views/request/_outgoing_correspondence.html.erb
@@ -1,13 +1,18 @@
<div class="outgoing correspondence" id="outgoing-<%=outgoing_message.id.to_s%>">
- <h2>
- <%= _("From:") %> <%= @info_request.user_name %><br>
- <br><%= simple_date(info_request_event.created_at) %>
- </h2>
- <%= render :partial => 'bubble', :locals => { :body => outgoing_message.get_body_for_html_display(), :attachments => nil } %>
- <p class="event_actions">
- <% if outgoing_message.status == 'ready' && !@info_request.is_external? %>
- <strong>Warning:</strong> This message has <strong>not yet been sent</strong> for an unknown reason.
- <% end %>
- <%= link_to _("Link to this"), outgoing_message_path(outgoing_message), :class => "link_to_this" %>
- </p>
+ <%- if not outgoing_message.user_can_view?(@user) %>
+ <%= render :partial => 'request/hidden_correspondence', :locals => { :message => outgoing_message }%>
+ <%- else %>
+ <%= render :partial => 'request/restricted_correspondence', :locals => {:message => outgoing_message } %>
+ <h2>
+ <%= _("From:") %> <%= @info_request.user_name %><br>
+ <br><%= simple_date(info_request_event.created_at) %>
+ </h2>
+ <%= render :partial => 'bubble', :locals => { :body => outgoing_message.get_body_for_html_display(), :attachments => nil } %>
+ <p class="event_actions">
+ <% if outgoing_message.status == 'ready' && !@info_request.is_external? %>
+ <strong>Warning:</strong> This message has <strong>not yet been sent</strong> for an unknown reason.
+ <% end %>
+ <%= link_to _("Link to this"), outgoing_message_path(outgoing_message), :class => "link_to_this" %>
+ </p>
+ <%- end %>
</div>
diff --git a/app/views/request/_restricted_correspondence.html.erb b/app/views/request/_restricted_correspondence.html.erb
new file mode 100644
index 000000000..745c4ff0e
--- /dev/null
+++ b/app/views/request/_restricted_correspondence.html.erb
@@ -0,0 +1,18 @@
+<% if message.prominence == 'hidden' %>
+ <p id="hidden_message">
+ <%- if !message.prominence_reason.blank? %>
+ <%= _('This message has prominence \'hidden\'. {{reason}} You can only see it because you are logged in as a super user.', :reason => message.prominence_reason) %>
+ <%- else %>
+ <%= _('This message has prominence \'hidden\'. You can only see it because you are logged in as a super user.') %>
+ <%- end %>
+ </p>
+<% end %>
+<% if message.prominence == 'requester_only' %>
+ <p id="hidden_message">
+ <%- if !message.prominence_reason.blank? %>
+ <%= _('This message is hidden, so that only you, the requester, can see it. {{reason}}', :reason => message.prominence_reason) %>
+ <%- else %>
+ <%= _('This message is hidden, so that only you, the requester, can see it. Please <a href="{{url}}">contact us</a> if you are not sure why.', :url => help_requesting_path.html_safe) %>
+ <%- end %>
+ </p>
+<% end %>