aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/request_controller.rb15
-rw-r--r--app/models/incoming_message.rb4
-rw-r--r--app/views/request/_hidden_correspondence.html.erb10
-rw-r--r--app/views/request/_incoming_correspondence.html.erb11
-rw-r--r--app/views/request/hidden_correspondence.html.erb4
5 files changed, 33 insertions, 11 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 0c1d9880c..6a927d327 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -683,9 +683,13 @@ class RequestController < ApplicationController
@info_request = incoming_message.info_request # used by view
return render_hidden
end
+ if !incoming_message.user_can_view?(authenticated_user)
+ @incoming_message = incoming_message # used by view
+ return render_hidden_message
+ end
# Is this a completely public request that we can cache attachments for
# to be served up without authentication?
- if incoming_message.info_request.all_can_view?
+ if incoming_message.info_request.all_can_view? && incoming_message.all_can_view?
@files_can_be_cached = true
end
end
@@ -945,5 +949,14 @@ class RequestController < ApplicationController
false
end
+ def render_hidden_message
+ respond_to do |format|
+ response_code = 410 # gone
+ format.html{ render :template => 'request/hidden_correspondence', :status => response_code }
+ format.any{ render :nothing => true, :status => response_code }
+ end
+ false
+ end
+
end
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 287120599..eea9c868e 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -73,6 +73,10 @@ class IncomingMessage < ActiveRecord::Base
Ability.can_view_with_prominence?(self.prominence, self.info_request, user)
end
+ def all_can_view?
+ self.prominence == 'normal'
+ end
+
def indexed_by_search?
self.prominence == 'normal'
end
diff --git a/app/views/request/_hidden_correspondence.html.erb b/app/views/request/_hidden_correspondence.html.erb
new file mode 100644
index 000000000..1deed6735
--- /dev/null
+++ b/app/views/request/_hidden_correspondence.html.erb
@@ -0,0 +1,10 @@
+<p id="hidden_message">
+ <%- if !message.prominence_reason.blank? %>
+ <%= _('This message has been hidden. {{reason}} Please <a href="{{url}}">contact us</a> if you have any questions.', :url => help_contact_path.html_safe, :reason => message.prominence_reason) %>
+ <%- else %>
+ <%= _('This message has been hidden. There are various reasons why we might have done this, sorry we can\'t be more specific here. Please <a href="{{url}}">contact us</a> if you have any questions.', :url => help_contact_path.html_safe) %>
+ <%- end %>
+ <% if message.prominence == 'requester_only' %>
+ <%= _('If you are the requester, then you may <a href="{{url}}">sign in</a> to view the message.', :url => signin_url(:r => request.fullpath).html_safe) %>
+ <% end %>
+</p>
diff --git a/app/views/request/_incoming_correspondence.html.erb b/app/views/request/_incoming_correspondence.html.erb
index 2293db66d..277999174 100644
--- a/app/views/request/_incoming_correspondence.html.erb
+++ b/app/views/request/_incoming_correspondence.html.erb
@@ -1,15 +1,6 @@
<div class="incoming correspondence <%= incoming_message.prominence %>" id="incoming-<%=incoming_message.id.to_s%>">
<%- if not incoming_message.user_can_view?(@user) %>
- <p id="hidden_message">
- <%- if !incoming_message.prominence_reason.blank? %>
- <%= _('This message has been hidden. {{reason}} Please <a href="{{url}}">contact us</a> if you have any questions.', :url => help_contact_path.html_safe, :reason => incoming_message.prominence_reason) %>
- <%- else %>
- <%= _('This message has been hidden. There are various reasons why we might have done this, sorry we can\'t be more specific here. Please <a href="{{url}}">contact us</a> if you have any questions.', :url => help_contact_path.html_safe) %>
- <%- end %>
- <% if incoming_message.prominence == 'requester_only' %>
- <%= _('If you are the requester, then you may <a href="{{url}}">sign in</a> to view the message.', :url => signin_url(:r => request.fullpath).html_safe) %>
- <% end %>
- </p>
+ <%= render :partial => 'request/hidden_correspondence', :locals => { :message => incoming_message }%>
<%- else %>
<% if incoming_message.prominence == 'hidden' %>
<p id="hidden_message">
diff --git a/app/views/request/hidden_correspondence.html.erb b/app/views/request/hidden_correspondence.html.erb
new file mode 100644
index 000000000..46bf3ee37
--- /dev/null
+++ b/app/views/request/hidden_correspondence.html.erb
@@ -0,0 +1,4 @@
+<% @title = _("Message has been removed") %>
+
+<h1><%=@title%></h1>
+<%= render :partial => 'request/hidden_correspondence', :locals => { :message => @incoming_message } %>