aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_request_controller.rb29
-rw-r--r--app/controllers/services_controller.rb11
-rw-r--r--app/models/info_request.rb8
-rw-r--r--app/views/admin_request/hidden_user_explanation.rhtml9
-rw-r--r--app/views/request/show.rhtml4
5 files changed, 60 insertions, 1 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb
index 3c700c567..2f1a92a50 100644
--- a/app/controllers/admin_request_controller.rb
+++ b/app/controllers/admin_request_controller.rb
@@ -6,6 +6,8 @@
#
# $Id: admin_request_controller.rb,v 1.42 2009-10-03 01:28:33 francis Exp $
+require 'ostruct'
+
class AdminRequestController < AdminController
def index
list
@@ -24,6 +26,15 @@ 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 => MySociety::Config.get("CONTACT_NAME", 'Alaveteli'),
+ :info_request => @info_request, :reason => params[:reason],
+ :info_request_url => 'http://' + MySociety::Config.get('DOMAIN') + request_url(@info_request),
+ :site_name => site_name)
+ template = File.read(File.join(File.dirname(__FILE__), "..", "views", "admin_request", "hidden_user_explanation.rhtml"))
+ @request_hidden_user_explanation = ERB.new(template).result(vars.instance_eval { binding })
end
def resend
@@ -323,6 +334,24 @@ class AdminRequestController < AdminController
redirect_to request_admin_url(info_request_event.info_request)
end
+ def hide_request
+ ActiveRecord::Base.transaction do
+ explanation = params[:explanation]
+ info_request = InfoRequest.find(params[:id])
+ info_request.set_described_state(params[:reason])
+ info_request.prominence = "requester_only"
+ info_request.save!
+
+ ContactMailer.deliver_from_admin_message(
+ info_request.user,
+ "hello",
+ params[:explanation]
+ )
+ flash[:notice] = _("Your message to {{recipient_user_name}} has been sent",:recipient_user_name=>CGI.escapeHTML(info_request.user.name))
+ redirect_to request_admin_url(info_request)
+ end
+ end
+
private
end
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb
index 225790d71..28dd2143d 100644
--- a/app/controllers/services_controller.rb
+++ b/app/controllers/services_controller.rb
@@ -21,4 +21,15 @@ class ServicesController < ApplicationController
end
render :text => text, :content_type => "text/plain" # XXX workaround the HTML validation in test suite
end
+ def hidden_user_explanation
+ info_request = InfoRequest.find(params[:info_request_id])
+ render :template => "admin_request/hidden_user_explanation",
+ :content_type => "text/plain",
+ :layout => false,
+ :locals => {:name_to => info_request.user.name,
+ :name_from => MySociety::Config.get("CONTACT_NAME", 'Alaveteli'),
+ :info_request => info_request, :reason => params[:reason],
+ :info_request_url => 'http://' + MySociety::Config.get('DOMAIN') + request_url(info_request),
+ :site_name => site_name}
+ end
end
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 47398dabb..3e28b5537 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -90,7 +90,9 @@ class InfoRequest < ActiveRecord::Base
'error_message',
'requires_admin',
'user_withdrawn',
- 'attention_requested'
+ 'attention_requested',
+ 'vexatious',
+ 'not_foi'
]
if @@custom_states_loaded
states += InfoRequest.theme_extra_states
@@ -812,6 +814,10 @@ public
_("Reported for administrator attention.")
elsif status == 'user_withdrawn'
_("Withdrawn by the requester.")
+ elsif status == 'vexatious'
+ _("Considered by administrators as vexatious and hidden from site.")
+ elsif status == 'not_foi'
+ _("Considered by administrators as not an FOI request and hidden from site.")
else
begin
return self.theme_display_status(status)
diff --git a/app/views/admin_request/hidden_user_explanation.rhtml b/app/views/admin_request/hidden_user_explanation.rhtml
new file mode 100644
index 000000000..aaea49fb6
--- /dev/null
+++ b/app/views/admin_request/hidden_user_explanation.rhtml
@@ -0,0 +1,9 @@
+Dear <%= name_to %>,
+
+Your request '<%= info_request.title %>' at <%= info_request_url %> has been reviewed by moderators.
+
+We consider it <% if reason == 'not_foi' %>is not a valid FOI request<% else %>to be vexatious<% end%>, and have therefore hidden it from other users. Please reply to this email if you would like to discuss this decision further.
+
+Yours,
+
+The <%= site_name %> team.
diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml
index 036ef06dd..eda61e7b4 100644
--- a/app/views/request/show.rhtml
+++ b/app/views/request/show.rhtml
@@ -120,6 +120,10 @@
There may be an explanation in the correspondence below.') %>
<% elsif @status == 'attention_requested' %>
<%= _('This request has been <strong>reported</strong> as needing administrator attention (perhaps because it is vexatious, or a request for personal information)') %>
+ <% elsif @status == 'vexatious' %>
+ <%= _('This request has been <strong>hidden</strong> from the site, because an administrator considers it vexatious') %>
+ <% elsif @status == 'not_foi' %>
+ <%= _('This request has been <strong>hidden</strong> from the site, because an administrator considers it not to be an FOI request') %>
<% else %>
<%= render :partial => 'general/custom_state_descriptions', :locals => { :status => @status } %>
<% end %>