diff --git a/app/controllers/moderator/post/posts_controller.rb b/app/controllers/moderator/post/posts_controller.rb index 160e4cebd..0aa862959 100644 --- a/app/controllers/moderator/post/posts_controller.rb +++ b/app/controllers/moderator/post/posts_controller.rb @@ -35,14 +35,14 @@ module Moderator def ban @post = ::Post.find(params[:id]) if params[:commit] == "Ban" - @post.update_column(:is_banned, true) + @post.ban! end redirect_to(post_path(@post), :notice => "Post was banned") end def unban @post = ::Post.find(params[:id]) - @post.update_attribute(:is_banned, false) + @post.unban! redirect_to(post_path(@post), :notice => "Post was unbanned") end end diff --git a/app/models/post.rb b/app/models/post.rb index d857ebc06..e2b55940a 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -797,6 +797,16 @@ class Post < ActiveRecord::Base destroy end + def ban! + update_column(:is_banned, true) + ModAction.create(:description => "banned post ##{id}") + end + + def unban! + update_column(:is_banned, false) + ModAction.create(:description => "unbanned post ##{id}") + end + def delete!(options = {}) if is_status_locked? self.errors.add(:is_status_locked, "; cannot delete post")