From 3aa27f5db14081460d2215bdf724a41d2b01b659 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Wed, 18 Dec 2013 13:13:35 +0000 Subject: Standardise explanation generation by using render_to_string --- app/controllers/admin_request_controller.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'app/controllers/admin_request_controller.rb') diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index 4d45ced8b..2f5f51c0f 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -26,15 +26,13 @@ class AdminRequestController < AdminController def show @info_request = InfoRequest.find(params[:id]) - # XXX is this *really* the only way to render a template to a - # variable, rather than to the response? - vars = OpenStruct.new(:name_to => @info_request.user_name, - :name_from => AlaveteliConfiguration::contact_name, - :info_request => @info_request, :reason => params[:reason], - :info_request_url => 'http://' + AlaveteliConfiguration::domain + request_url(@info_request), - :site_name => site_name) - template = File.read(File.join(File.dirname(__FILE__), "..", "views", "admin_request", "hidden_user_explanation.html.erb")) - @request_hidden_user_explanation = ERB.new(template).result(vars.instance_eval { binding }) + vars_for_explanation = {:reason => params[:reason], + :info_request => @info_request, + :name_to => @info_request.user_name, + :name_from => AlaveteliConfiguration::contact_name, + :info_request_url => request_url(@info_request, :only_path => false)} + @request_hidden_user_explanation = render_to_string(:template => "admin_request/hidden_user_explanation", + :locals => vars_for_explanation) end def resend -- cgit v1.2.3 From 75ea3f8298da5943c5b762dc4304b85769b391e1 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Wed, 18 Dec 2013 19:29:01 +0000 Subject: Allow from_admin_message to take a name and email. Previously it accepted a user, but for this usage we won't necessarily have one. --- app/controllers/admin_request_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/controllers/admin_request_controller.rb') diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index 4d45ced8b..ca4179acb 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -281,7 +281,8 @@ class AdminRequestController < AdminController if ! info_request.is_external? ContactMailer.from_admin_message( - info_request.user, + info_request.user.name, + info_request.user.email, subject, params[:explanation].strip.html_safe ).deliver -- cgit v1.2.3