diff options
-rw-r--r-- | app/models/info_request.rb | 5 | ||||
-rw-r--r-- | app/views/request/_after_actions.rhtml | 7 | ||||
-rw-r--r-- | app/views/request/_correspondence.rhtml | 10 | ||||
-rw-r--r-- | app/views/request/_followup.rhtml | 40 | ||||
-rw-r--r-- | public/stylesheets/theme.css | 2 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 16 |
6 files changed, 61 insertions, 19 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 88a02cc2c..92322f74f 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -922,10 +922,13 @@ public end # List of incoming messages to followup, by unique email - def who_can_followup_to + def who_can_followup_to(skip_message = nil) ret = [] done = {} for incoming_message in self.incoming_messages.reverse + if incoming_message == skip_message + next + end incoming_message.safe_mail_from email = OutgoingMailer.email_for_followup(self, incoming_message) diff --git a/app/views/request/_after_actions.rhtml b/app/views/request/_after_actions.rhtml index 30bcf3046..47ef85069 100644 --- a/app/views/request/_after_actions.rhtml +++ b/app/views/request/_after_actions.rhtml @@ -19,13 +19,12 @@ <div id="owner_actions"> <strong><%= _('{{info_request_user_name}} only:',:info_request_user_name=>h(@info_request.user.name)) %></strong> <ul> + <li> <% if @last_response.nil? %> - <%= link_to "Send follow up to " + OutgoingMailer.name_for_followup(@info_request, @last_response), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "#followup" %> + <%= link_to _("Write a reply"), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "#followup" %> <% else %> - <% foi_cache(:controller => "request", :action => "show_response", :id => @info_request.id, :incoming_message_id => @last_response.id, :only_path => true, :template => "_after_actions", :section => "reply_to_link") do %> - <%= link_to "Reply to " + OutgoingMailer.name_for_followup(@info_request, @last_response), show_response_url(:id => @info_request.id, :incoming_message_id => @last_response.id) + "#followup" %> - <% end %> + <%= link_to _("Write a reply"), show_response_url(:id => @info_request.id, :incoming_message_id => @last_response.id) + "#followup" %> <% end %> </li> <% if !@old_unclassified %> diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.rhtml index aa33f3bc4..280e8f50e 100644 --- a/app/views/request/_correspondence.rhtml +++ b/app/views/request/_correspondence.rhtml @@ -25,12 +25,7 @@ if not incoming_message.nil? <% if !@user.nil? && @user.admin_page_links? %> <%= link_to "Admin", admin_url("request/show_raw_email/" + incoming_message.raw_email_id.to_s) %> | <% end %> - <%= link_to _("Link to this"), incoming_message_url(incoming_message), :class => "link_to_this" %> | - <% if incoming_message.valid_to_reply_to? %> - <%= link_to _("Reply to this message"), show_response_url(:id => incoming_message.info_request.id, :incoming_message_id => incoming_message.id) + "#followup" %> - <% else %> - <%= link_to _("Send follow up to the main FOI contact"), show_response_no_followup_url(:id => outgoing_message.info_request.id, :incoming_message_id => nil) + "#followup" %> - <% end %> + <%= link_to _("Link to this"), incoming_message_url(incoming_message), :class => "link_to_this" %> </p> </div> <% @@ -58,8 +53,7 @@ elsif [ 'sent', 'followup_sent' ].include?(info_request_event.event_type) <% end %> --> - <%= link_to _("Link to this"), outgoing_message_url(outgoing_message), :class => "link_to_this" %> | - <%= link_to _("Send follow up to the main FOI contact"), show_response_no_followup_url(:id => outgoing_message.info_request.id, :incoming_message_id => nil) + "#followup" %> + <%= link_to _("Link to this"), outgoing_message_url(outgoing_message), :class => "link_to_this" %> </p> </div> <% elsif [ 'resent', 'followup_resent' ].include?(info_request_event.event_type) %> diff --git a/app/views/request/_followup.rhtml b/app/views/request/_followup.rhtml index a15f2912d..4de2ce853 100644 --- a/app/views/request/_followup.rhtml +++ b/app/views/request/_followup.rhtml @@ -1,17 +1,47 @@ +<style> + p.event_actions { + display: none; + } +</style> <div id="followup"> - + <% if (incoming_message.nil? || !incoming_message.valid_to_reply_to?) + name_for_followup = _("the main FOI contact at {{public_body}}", :public_body => h(OutgoingMailer.name_for_followup(@info_request, nil))) + else + name_for_followup = h(OutgoingMailer.name_for_followup(@info_request, incoming_message)) + end %> <% if @internal_review %> - <h1><%= _('Request an internal review from') %> <%=h OutgoingMailer.name_for_followup(@info_request, nil) %> + <h1><%= _('Request an internal review from {{person_or_body}}', :person_or_body => name_for_followup) %> </h1> <% elsif incoming_message.nil? || !incoming_message.valid_to_reply_to? %> - <h2><%= _('Send a public follow up message to') %> <%=h OutgoingMailer.name_for_followup(@info_request, nil) %> + <h2><%= _('Send a public follow up message to {{person_or_body}}', :person_or_body => name_for_followup) %> </h2> <% else %> - <h2><%= _('Send a public reply to') %> - <%=h OutgoingMailer.name_for_followup(@info_request, incoming_message) %> + <h2><%= _('Send a public reply to {{person_or_body}}', :person_or_body => name_for_followup) %> </h2> <% end %> +<% if @info_request.who_can_followup_to(incoming_message).count > 0 %> +<div id="other_recipients"> + <%= _("Don't want to address your message to {{person_or_body}}? You can also write to:", :person_or_body => name_for_followup) %> + <ul> +<% @info_request.who_can_followup_to(incoming_message).each do |name, email, id| %> + <% if id.nil? && !incoming_message.nil? && incoming_message.valid_to_reply_to? %> + <li><%= link_to(_("the main FOI contact address for {{public_body}}", :public_body => name), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil)) %></li> + <% else %> + <% if !id.nil? %> + <% if @info_request.public_body.request_email == email %> + <% if !incoming_message.nil? %> + <li><%= link_to(_("the main FOI contact address for {{public_body}}", :public_body => name), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil)) %></li> + <% end %> + <% else %> + <li><%= link_to name, show_response_url(:id => @info_request.id, :incoming_message_id => id)%></li> + <% end %> + <% end %> + <% end %> +<% end %> +</ul> +</div> +<% end %> <% if @info_request.allow_new_responses_from == 'nobody' %> <p><%= _('Follow ups and new responses to this request have been stopped to prevent spam. Please <a href="{{url}}">contact us</a> if you are {{user_link}} and need to send a follow up.',:user_link=>user_link(@info_request.user), :url=>help_contact_path) %></p> <% else %> diff --git a/public/stylesheets/theme.css b/public/stylesheets/theme.css index fc8efe377..4b7b1b2f0 100644 --- a/public/stylesheets/theme.css +++ b/public/stylesheets/theme.css @@ -1075,7 +1075,7 @@ a.link_to_this { margin: 20px 0px 30px 0px; } -#notice, .describe_state_form { +#notice, .describe_state_form, #other_recipients { font-size: 12px; font-weight: normal; padding: 10px 20px 10px 20px; diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index b4aef8470..aa3027c00 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -533,6 +533,22 @@ describe RequestController, "when viewing an individual response for reply/follo response.should render_template('show_response') end + it "should offer the opportunity to reply to the main address" do + session[:user_id] = users(:bob_smith_user).id + get :show_response, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message) + response.body.should have_tag("div#other_recipients ul li", /the main FOI contact address for/) + end + + it "should offer an opportunity to reply to another address" do + session[:user_id] = users(:bob_smith_user).id + ir = info_requests(:fancy_dog_request) + ir.allow_new_responses_from = "anybody" + ir.save! + receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "Frob <frob@bonce.com>") + get :show_response, :id => ir.id, :incoming_message_id => incoming_messages(:useless_incoming_message) + response.body.should have_tag("div#other_recipients ul li", /Frob/) + end + it "should not show individual responses if request hidden, even if request owner" do ir = info_requests(:fancy_dog_request) ir.prominence = 'hidden' |