aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/admin_outgoing_message_controller.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-09-24 09:23:44 +0100
committerLouise Crow <louise.crow@gmail.com>2013-09-24 09:23:44 +0100
commit7d9b66d1ff31afa8d73ea1a81f4e612e41f89cb0 (patch)
tree5206d9fbaf8d6af58bdaa35cefdfeb34a88c84ff /app/controllers/admin_outgoing_message_controller.rb
parent40a28fa2fe21d752a15c11938791d620dd31d17f (diff)
parent8e7432be764254e6a50e6a06e77bb93bb5bba9fe (diff)
Merge branch 'release/0.14' into wdtk
Conflicts: app/views/request/show.html.erb
Diffstat (limited to 'app/controllers/admin_outgoing_message_controller.rb')
-rw-r--r--app/controllers/admin_outgoing_message_controller.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/app/controllers/admin_outgoing_message_controller.rb b/app/controllers/admin_outgoing_message_controller.rb
new file mode 100644
index 000000000..ec0981677
--- /dev/null
+++ b/app/controllers/admin_outgoing_message_controller.rb
@@ -0,0 +1,47 @@
+class AdminOutgoingMessageController < AdminController
+
+ def edit
+ @outgoing_message = OutgoingMessage.find(params[:id])
+ end
+
+ def destroy
+ @outgoing_message = OutgoingMessage.find(params[:outgoing_message_id])
+ @info_request = @outgoing_message.info_request
+ outgoing_message_id = @outgoing_message.id
+
+ @outgoing_message.fully_destroy
+ @outgoing_message.info_request.log_event("destroy_outgoing",
+ { :editor => admin_current_user(), :deleted_outgoing_message_id => outgoing_message_id })
+
+ flash[:notice] = 'Outgoing message successfully destroyed.'
+ redirect_to admin_request_show_url(@info_request)
+ end
+
+ def update
+ @outgoing_message = OutgoingMessage.find(params[:id])
+
+ old_body = @outgoing_message.body
+ old_prominence = @outgoing_message.prominence
+ old_prominence_reason = @outgoing_message.prominence_reason
+ @outgoing_message.prominence = params[:outgoing_message][:prominence]
+ @outgoing_message.prominence_reason = params[:outgoing_message][:prominence_reason]
+ @outgoing_message.body = params[:outgoing_message][:body]
+ if @outgoing_message.save
+ @outgoing_message.info_request.log_event("edit_outgoing",
+ { :outgoing_message_id => @outgoing_message.id,
+ :editor => admin_current_user(),
+ :old_body => old_body,
+ :body => @outgoing_message.body,
+ :old_prominence => old_prominence,
+ :old_prominence_reason => old_prominence_reason,
+ :prominence => @outgoing_message.prominence,
+ :prominence_reason => @outgoing_message.prominence_reason })
+ flash[:notice] = 'Outgoing message successfully updated.'
+ expire_for_request(@outgoing_message.info_request)
+ redirect_to admin_request_show_url(@outgoing_message.info_request)
+ else
+ render :action => 'edit'
+ end
+ end
+
+end