fixes #2114
This commit is contained in:
@@ -848,7 +848,8 @@ class Post < ActiveRecord::Base
|
||||
def update_has_children_flag_for(post_id)
|
||||
return if post_id.nil?
|
||||
has_children = Post.where("parent_id = ?", post_id).exists?
|
||||
execute_sql("UPDATE posts SET has_children = ? WHERE id = ?", has_children, post_id)
|
||||
has_active_children = Post.where("parent_id = ? and is_deleted = ?", post_id, false).exists?
|
||||
execute_sql("UPDATE posts SET has_children = ?, has_active_children = ? WHERE id = ?", has_children, has_active_children, post_id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -924,6 +925,13 @@ class Post < ActiveRecord::Base
|
||||
def parent_exists?
|
||||
Post.exists?(parent_id)
|
||||
end
|
||||
|
||||
def has_visible_children?
|
||||
return true if has_active_children?
|
||||
return true if has_children? && CurrentUser.user.show_deleted_children?
|
||||
return true if has_children? && is_deleted?
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
module DeletionMethods
|
||||
|
||||
Reference in New Issue
Block a user