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 From 7330ad14103642fb8c13707fe4ce61f67ab649cf Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Mon, 25 Mar 2013 16:22:06 +1100 Subject: ActsAsXapian doesn't need to be referenced from the global namespace --- app/controllers/request_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index ad1918005..cad5d5597 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -101,7 +101,7 @@ class RequestController < ApplicationController # ... requests that have similar imporant terms begin limit = 10 - @xapian_similar = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events, + @xapian_similar = ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events, :limit => limit, :collapse_by_prefix => 'request_collapse') @xapian_similar_more = (@xapian_similar.matches_estimated > limit) rescue @@ -149,7 +149,7 @@ class RequestController < ApplicationController render :template => 'request/hidden', :status => 410 # gone return end - @xapian_object = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events, + @xapian_object = ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events, :offset => (@page - 1) * @per_page, :limit => @per_page, :collapse_by_prefix => 'request_collapse') @matches_estimated = @xapian_object.matches_estimated @show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated -- cgit v1.2.3 From eff801d14ab7d5be11518190a10ebf0b0deb3db2 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Fri, 7 Jun 2013 17:07:00 +0100 Subject: Allow the donation url to be configured. Closes #909. --- app/controllers/request_controller.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 880a7b4b4..42693f867 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -461,9 +461,19 @@ class RequestController < ApplicationController when 'rejected' _("Oh no! Sorry to hear that your request was refused. Here is what to do now.") when 'successful' - _("

We're glad you got all the information that you wanted. If you write about or make use of the information, please come back and add an annotation below saying what you did.

If you found {{site_name}} useful, make a donation to the charity which runs it.

", :site_name=>site_name, :donation_url => "http://www.mysociety.org/donate/") + if AlaveteliConfiguration::donation_url.blank? + _("

We're glad you got all the information that you wanted. If you write about or make use of the information, please come back and add an annotation below saying what you did.

") + else + _("

We're glad you got all the information that you wanted. If you write about or make use of the information, please come back and add an annotation below saying what you did.

If you found {{site_name}} useful, make a donation to the charity which runs it.

", + :site_name => site_name, :donation_url => AlaveteliConfiguration::donation_url) + end when 'partially_successful' - _("

We're glad you got some of the information that you wanted. If you found {{site_name}} useful, make a donation to the charity which runs it.

If you want to try and get the rest of the information, here's what to do now.

", :site_name=>site_name, :donation_url=>"http://www.mysociety.org/donate/") + if AlaveteliConfiguration::donation_url.blank? + _("

We're glad you got some of the information that you wanted.

If you want to try and get the rest of the information, here's what to do now.

") + else + _("

We're glad you got some of the information that you wanted. If you found {{site_name}} useful, make a donation to the charity which runs it.

If you want to try and get the rest of the information, here's what to do now.

", + :site_name => site_name, :donation_url => AlaveteliConfiguration::donation_url) + end when 'waiting_clarification' _("Please write your follow up message containing the necessary clarifications below.") when 'gone_postal' -- cgit v1.2.3