aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_request_controller.rb21
-rw-r--r--app/models/info_request_event.rb4
-rw-r--r--app/views/admin_request/edit_outgoing.rhtml26
-rw-r--r--app/views/admin_request/show.rhtml5
4 files changed, 47 insertions, 9 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb
index d480084c4..f474a3beb 100644
--- a/app/controllers/admin_request_controller.rb
+++ b/app/controllers/admin_request_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: admin_request_controller.rb,v 1.1 2007-12-17 00:34:55 francis Exp $
+# $Id: admin_request_controller.rb,v 1.2 2008-01-07 13:26:46 francis Exp $
class AdminRequestController < ApplicationController
layout "admin"
@@ -29,10 +29,21 @@ class AdminRequestController < ApplicationController
redirect_to admin_url('request/show/' + @outgoing_message.info_request.id.to_s)
end
-# def destroy
-# InfoRequest.find(params[:id]).destroy
-# redirect_to admin_url('request/list')
-# end
+ def edit_outgoing
+ @outgoing_message = OutgoingMessage.find(params[:id])
+ end
+
+ def update_outgoing
+ @outgoing_message = OutgoingMessage.find(params[:id])
+ old_body = @outgoing_message.body
+ if @outgoing_message.update_attributes(params[:outgoing_message])
+ @outgoing_message.info_request.log_event("edit_outgoing", { :outgoing_message_id => @outgoing_message.id, :editor => admin_http_auth_user(), :old_body => old_body, :body => @outgoing_message.body })
+ flash[:notice] = 'OutgoingMessage was successfully updated.'
+ redirect_to admin_url('request/show/' + @outgoing_message.info_request.id.to_s)
+ else
+ render :action => 'edit_outgoing'
+ end
+ end
private
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index a184be2ac..6c0ccc585 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -15,14 +15,14 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request_event.rb,v 1.3 2008-01-04 11:19:18 francis Exp $
+# $Id: info_request_event.rb,v 1.4 2008-01-07 13:26:46 francis Exp $
class InfoRequestEvent < ActiveRecord::Base
belongs_to :info_request
validates_presence_of :info_request
validates_presence_of :event_type
- validates_inclusion_of :event_type, :in => ['sent', 'resent']
+ validates_inclusion_of :event_type, :in => ['sent', 'resent', 'edit_outgoing']
# We store YAML version of parameters in the database
def params=(params)
diff --git a/app/views/admin_request/edit_outgoing.rhtml b/app/views/admin_request/edit_outgoing.rhtml
new file mode 100644
index 000000000..cbeff25f8
--- /dev/null
+++ b/app/views/admin_request/edit_outgoing.rhtml
@@ -0,0 +1,26 @@
+<h1>Edit outgoing message</h1>
+
+<%= error_messages_for 'outgoing_message' %>
+
+<% form_tag '../update_outgoing/' + @outgoing_message.id.to_s do %>
+
+ <p><label for="outgoing_message_body">Body of message</label><br/>
+ <%= text_area 'outgoing_message', 'body', :rows => 10, :cols => 60 %></p>
+
+ <p><strong>Note:</strong> This is mainly to be used to excise information
+ that users inadvertently put in their messages, not realising it would be
+ public. It will already have been sent to the public body, and their
+ reply may also include that information and be automatically published on
+ this site.</p>
+
+ <p>You could also use this to edit a message before resending it, but
+ only the edited version will be shown on the public page if you do that.</p>
+
+ <%= submit_tag 'Save' %>
+<% end %>
+
+<p>
+<%= link_to 'Show', '../show/' + @outgoing_message.info_request.id.to_s %> |
+<%= link_to 'List all', '../list' %>
+</p>
+
diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml
index b3ad12083..394634470 100644
--- a/app/views/admin_request/show.rhtml
+++ b/app/views/admin_request/show.rhtml
@@ -31,9 +31,10 @@
<% end %>
<td>
<% form_tag '../resend' do %>
- <%= hidden_field_tag 'outgoing_message_id', outgoing_message.id %>
- <%= submit_tag "Resend" %>
+ <%= hidden_field_tag 'outgoing_message_id', outgoing_message.id %>
+ <%= submit_tag "Resend" %>
<% end %>
+ <%= link_to "Edit", '../edit_outgoing/' + outgoing_message.id.to_s %>
</td>
</tr>
<% end %>