aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/admin_comment_controller.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-12-18 15:42:53 +0000
committerLouise Crow <louise.crow@gmail.com>2014-12-18 15:42:53 +0000
commitbbdcb09cb9eeb94e3244a22b1129a1e9521947f4 (patch)
tree4ad15f4138796087c32957261e8b9e7b6f59887b /app/controllers/admin_comment_controller.rb
parent5cfcdaac505e60914ee4398cfe431bd5d21b58ed (diff)
parentabdc92fd922dd82da85f7c00bdb50e85ed047714 (diff)
Merge branch 'restful-admin-routes' into rails-3-develop
Diffstat (limited to 'app/controllers/admin_comment_controller.rb')
-rw-r--r--app/controllers/admin_comment_controller.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/app/controllers/admin_comment_controller.rb b/app/controllers/admin_comment_controller.rb
new file mode 100644
index 000000000..0aafb122a
--- /dev/null
+++ b/app/controllers/admin_comment_controller.rb
@@ -0,0 +1,36 @@
+# app/controllers/admin_comment_controller.rb:
+# Controller for editing comments from the admin interface.
+#
+# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
+# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
+
+class AdminCommentController < AdminController
+
+ def edit
+ @comment = Comment.find(params[:id])
+ end
+
+ def update
+ @comment = Comment.find(params[:id])
+
+ old_body = @comment.body
+ old_visible = @comment.visible
+ @comment.visible = params[:comment][:visible] == "true" ? true : false
+
+ if @comment.update_attributes(params[:comment])
+ @comment.info_request.log_event("edit_comment",
+ { :comment_id => @comment.id,
+ :editor => admin_current_user(),
+ :old_body => old_body,
+ :body => @comment.body,
+ :old_visible => old_visible,
+ :visible => @comment.visible,
+ })
+ flash[:notice] = 'Comment successfully updated.'
+ redirect_to admin_request_url(@comment.info_request)
+ else
+ render :action => 'edit'
+ end
+ end
+
+end