Post#expunge!: fix remove_from_all_pools to clear deleted pools.
* Change Post#pools to return all pools, including deleted pools. This fixes remove_all_from_pools to remove the post from deleted pools too. * Change other users of Post#pools to explicitly select undeleted pools.
This commit is contained in:
@@ -1051,12 +1051,12 @@ class Post < ApplicationRecord
|
||||
@pools ||= begin
|
||||
return Pool.none if pool_string.blank?
|
||||
pool_ids = pool_string.scan(/\d+/)
|
||||
Pool.undeleted.where(id: pool_ids).series_first
|
||||
Pool.where(id: pool_ids).series_first
|
||||
end
|
||||
end
|
||||
|
||||
def has_active_pools?
|
||||
pools.length > 0
|
||||
pools.undeleted.length > 0
|
||||
end
|
||||
|
||||
def belongs_to_pool?(pool)
|
||||
@@ -1101,7 +1101,7 @@ class Post < ApplicationRecord
|
||||
def set_pool_category_pseudo_tags
|
||||
self.pool_string = (pool_string.scan(/\S+/) - ["pool:series", "pool:collection"]).join(" ")
|
||||
|
||||
pool_categories = pools.select("category").map(&:category)
|
||||
pool_categories = pools.undeleted.pluck(:category)
|
||||
if pool_categories.include?("series")
|
||||
self.pool_string = "#{pool_string} pool:series".strip
|
||||
end
|
||||
|
||||
@@ -189,7 +189,7 @@ class PostPresenter < Presenter
|
||||
end
|
||||
|
||||
def has_nav_links?(template)
|
||||
(CurrentUser.user.enable_sequential_post_navigation && template.params[:tags].present? && template.params[:tags] !~ /(?:^|\s)(?:order|ordfav|ordpool):/) || @post.pools.any? || @post.favorite_groups(active_id=template.params[:favgroup_id]).any?
|
||||
(CurrentUser.user.enable_sequential_post_navigation && template.params[:tags].present? && template.params[:tags] !~ /(?:^|\s)(?:order|ordfav|ordpool):/) || @post.pools.undeleted.any? || @post.favorite_groups(active_id=template.params[:favgroup_id]).any?
|
||||
end
|
||||
|
||||
def post_footer_for_pool_html(template)
|
||||
@@ -211,13 +211,13 @@ class PostPresenter < Presenter
|
||||
return if pool.nil?
|
||||
html += pool_link_html(template, pool, :include_rel => true)
|
||||
|
||||
other_pools = @post.pools.where("id <> ?", template.params[:pool_id]).series_first
|
||||
other_pools = @post.pools.undeleted.where("id <> ?", template.params[:pool_id]).series_first
|
||||
other_pools.each do |other_pool|
|
||||
html += pool_link_html(template, other_pool)
|
||||
end
|
||||
else
|
||||
first = true
|
||||
pools = @post.pools.series_first
|
||||
pools = @post.pools.undeleted
|
||||
pools.each do |pool|
|
||||
if first && template.params[:tags].blank? && template.params[:favgroup_id].blank?
|
||||
html += pool_link_html(template, pool, :include_rel => true)
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
</li>
|
||||
<li><strong>Source</strong>: <%= post.source %></li>
|
||||
<% if post.has_active_pools? %>
|
||||
<li><strong>Pools</strong>: <%= render "pools/inline_list", pools: post.pools %></li>
|
||||
<li><strong>Pools</strong>: <%= render "pools/inline_list", pools: post.pools.undeleted %></li>
|
||||
<% end %>
|
||||
<li><strong>Tags</strong>: <%= post.presenter.inline_tag_list_html(self) %></li>
|
||||
</ul>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<%= render "posts/partials/show/search_seq", :post => post %>
|
||||
<% end %>
|
||||
|
||||
<% if post.pools.any? %>
|
||||
<% if post.pools.undeleted.any? %>
|
||||
<%= render "posts/partials/show/pools", :post => post %>
|
||||
<% end %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user