Keep track of who deletes forum post/topic/comment

Previously it would look like the creator of it was the one who
deleted/undeleted it, even if it was someone else.
This commit is contained in:
Toks
2015-07-11 13:20:47 -04:00
parent 87d3058258
commit fe7f3d8204
4 changed files with 13 additions and 5 deletions

View File

@@ -51,7 +51,7 @@ class ForumTopicsController < ApplicationController
def destroy
@forum_topic = ForumTopic.find(params[:id])
check_privilege(@forum_topic)
@forum_topic.update_column(:is_deleted, true)
@forum_topic.delete!
flash[:notice] = "Topic deleted"
respond_with(@forum_topic)
end
@@ -59,7 +59,7 @@ class ForumTopicsController < ApplicationController
def undelete
@forum_topic = ForumTopic.find(params[:id])
check_privilege(@forum_topic)
@forum_topic.update_column(:is_deleted, false)
@forum_topic.undelete!
flash[:notice] = "Topic undeleted"
respond_with(@forum_topic)
end

View File

@@ -173,7 +173,7 @@ class Comment < ActiveRecord::Base
end
def delete!
update_attribute(:is_deleted, true)
update_attributes(:is_deleted => true)
end
end

View File

@@ -128,12 +128,12 @@ class ForumPost < ActiveRecord::Base
end
def delete!
update_attribute(:is_deleted, true)
update_attributes(:is_deleted => true)
update_topic_updated_at_on_delete
end
def undelete!
update_attribute(:is_deleted, false)
update_attributes(:is_deleted => false)
update_topic_updated_at_on_undelete
end

View File

@@ -151,4 +151,12 @@ class ForumTopic < ActiveRecord::Base
topic.update_attribute(:response_count, topic.response_count + self.posts.length)
self.update_columns(:response_count => 0, :is_deleted => true)
end
def delete!
update_attributes(:is_deleted => true)
end
def undelete!
update_attributes(:is_deleted => false)
end
end