fixes #2110
This commit is contained in:
@@ -55,14 +55,14 @@ class ForumPostsController < ApplicationController
|
||||
def destroy
|
||||
@forum_post = ForumPost.find(params[:id])
|
||||
check_privilege(@forum_post)
|
||||
@forum_post.update_column(:is_deleted, true)
|
||||
@forum_post.delete!
|
||||
respond_with(@forum_post)
|
||||
end
|
||||
|
||||
def undelete
|
||||
@forum_post = ForumPost.find(params[:id])
|
||||
check_privilege(@forum_post)
|
||||
@forum_post.update_attribute(:is_deleted, false)
|
||||
@forum_post.undelete!
|
||||
respond_with(@forum_post)
|
||||
end
|
||||
|
||||
|
||||
@@ -119,8 +119,18 @@ class ForumPost < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def delete!
|
||||
update_attribute(:is_deleted, true)
|
||||
update_topic_updated_at_on_destroy
|
||||
end
|
||||
|
||||
def undelete!
|
||||
update_attribute(:is_deleted, true)
|
||||
update_topic_updated_at_on_create
|
||||
end
|
||||
|
||||
def update_topic_updated_at_on_destroy
|
||||
max = ForumPost.where(:topic_id => topic.id).maximum(:updated_at)
|
||||
max = ForumPost.where(:topic_id => topic.id, :is_deleted => false).maximum(:updated_at)
|
||||
if max
|
||||
ForumTopic.update_all(["response_count = response_count - 1, updated_at = ?", max], {:id => topic.id})
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user