From 2f7a41599ad936bbf117c1ea6e8356cb6e92b5a6 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 22 Mar 2013 12:56:11 +1100 Subject: Add first pass at page for reporting a request --- app/controllers/request_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index ad1918005..3f73fe65c 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -699,6 +699,10 @@ class RequestController < ApplicationController redirect_to request_url(info_request) end + def new_report_request + @info_request = InfoRequest.find_by_url_title!(params[:url_title]) + end + # special caching code so mime types are handled right around_filter :cache_attachments, :only => [ :get_attachment, :get_attachment_as_html ] def cache_attachments -- cgit v1.2.3 From 67dc39ed036d1aa27d9f49dfddb04b51ff8710d2 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 22 Mar 2013 13:23:26 +1100 Subject: Only allow reporting a request when logged in --- app/controllers/request_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 3f73fe65c..dc8db4ab1 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -701,6 +701,11 @@ class RequestController < ApplicationController def new_report_request @info_request = InfoRequest.find_by_url_title!(params[:url_title]) + if authenticated?( + :web => _("To report this request"), + :email => _("Then you can report the request '{{title}}'", :title => @info_request.title), + :email_subject => _("Report an offensive or unsuitable request")) + end end # special caching code so mime types are handled right -- cgit v1.2.3 From 06c1d5844c7da1f03acb930afe29f6c7221c62ba Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 22 Mar 2013 14:22:26 +1100 Subject: Posted reason and message gets sent out in the email --- app/controllers/request_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index dc8db4ab1..a018d76c9 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -689,7 +689,7 @@ class RequestController < ApplicationController ) if !info_request.attention_requested - info_request.set_described_state('attention_requested', @user) + info_request.set_described_state('attention_requested', @user, "Reason: #{params[:reason]}\n\n#{params[:message]}") info_request.attention_requested = true # tells us if attention has ever been requested info_request.save! flash[:notice] = _("This request has been reported for administrator attention") -- cgit v1.2.3 From 661ad52ef88de7afcbd7820d8283057764f4d1ac Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 22 Mar 2013 14:50:01 +1100 Subject: Only allow posts for reporting request. Don't try redirection when not logged in --- app/controllers/request_controller.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index a018d76c9..e12c408ea 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -682,19 +682,15 @@ class RequestController < ApplicationController def report_request info_request = InfoRequest.find_by_url_title!(params[:url_title]) - return if !authenticated?( - :web => _("To report this FOI request"), - :email => _("Then you can report the request '{{title}}'", :title => info_request.title), - :email_subject => _("Report an offensive or unsuitable request") - ) - - if !info_request.attention_requested + if !authenticated_user + flash[:notice] = _("You need to be logged in to report a request for administrator attention") + elsif info_request.attention_requested + flash[:notice] = _("This request has already been reported for administrator attention") + else info_request.set_described_state('attention_requested', @user, "Reason: #{params[:reason]}\n\n#{params[:message]}") info_request.attention_requested = true # tells us if attention has ever been requested info_request.save! flash[:notice] = _("This request has been reported for administrator attention") - else - flash[:notice] = _("This request has already been reported for administrator attention") end redirect_to request_url(info_request) end -- cgit v1.2.3 From ca4ae410e70ab490ae4c8cad8839f41783c89ef7 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 22 Mar 2013 15:02:30 +1100 Subject: Extract method --- app/controllers/request_controller.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index e12c408ea..12ba1a3a9 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -687,9 +687,7 @@ class RequestController < ApplicationController elsif info_request.attention_requested flash[:notice] = _("This request has already been reported for administrator attention") else - info_request.set_described_state('attention_requested', @user, "Reason: #{params[:reason]}\n\n#{params[:message]}") - info_request.attention_requested = true # tells us if attention has ever been requested - info_request.save! + info_request.report!(params[:reason], params[:message], @user) flash[:notice] = _("This request has been reported for administrator attention") end redirect_to request_url(info_request) -- cgit v1.2.3 From 5fbb8f4357fd759cadfa0191694d3bad49d86a90 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 22 Mar 2013 16:48:48 +1100 Subject: Move reporting actions to their own controller --- app/controllers/request_controller.rb | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 12ba1a3a9..7bc37de5e 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -680,28 +680,6 @@ class RequestController < ApplicationController end end - def report_request - info_request = InfoRequest.find_by_url_title!(params[:url_title]) - if !authenticated_user - flash[:notice] = _("You need to be logged in to report a request for administrator attention") - elsif info_request.attention_requested - flash[:notice] = _("This request has already been reported for administrator attention") - else - info_request.report!(params[:reason], params[:message], @user) - flash[:notice] = _("This request has been reported for administrator attention") - end - redirect_to request_url(info_request) - end - - def new_report_request - @info_request = InfoRequest.find_by_url_title!(params[:url_title]) - if authenticated?( - :web => _("To report this request"), - :email => _("Then you can report the request '{{title}}'", :title => @info_request.title), - :email_subject => _("Report an offensive or unsuitable request")) - end - end - # special caching code so mime types are handled right around_filter :cache_attachments, :only => [ :get_attachment, :get_attachment_as_html ] def cache_attachments -- cgit v1.2.3