users: add 'show deleted posts' account setting.

Add an account setting to always show deleted posts in searches. This
only applies to searches, not to thumbnails in other places.

Fixes #4512.
This commit is contained in:
evazion
2022-05-01 00:47:35 -05:00
parent f117049750
commit f434abc59a
5 changed files with 10 additions and 3 deletions

View File

@@ -303,7 +303,7 @@ module ApplicationHelper
id name level level_string theme always_resize_images can_upload_free
can_approve_posts disable_categorized_saved_searches
disable_mobile_gestures disable_post_tooltips enable_safe_mode
show_deleted_children style_usernames
show_deleted_posts show_deleted_children style_usernames
default_image_size
] + User::Roles.map { |role| :"is_#{role}?" }

View File

@@ -12,11 +12,12 @@ module PostSets
MAX_SIDEBAR_TAGS = 25
MAX_WILDCARD_TAGS = PostQueryBuilder::MAX_WILDCARD_TAGS
attr_reader :page, :format, :tag_string, :query, :post_query, :normalized_query, :show_votes
attr_reader :current_user, :page, :format, :tag_string, :query, :post_query, :normalized_query, :show_votes
delegate :tag, to: :post_query
alias_method :show_votes?, :show_votes
def initialize(tags, page = 1, per_page = nil, user: CurrentUser.user, format: "html", show_votes: false)
@current_user = user
@query = PostQueryBuilder.new(tags, user, tag_limit: user.tag_query_limit, safe_mode: CurrentUser.safe_mode?)
@post_query = PostQuery.normalize(tags, current_user: user, tag_limit: user.tag_query_limit, safe_mode: CurrentUser.safe_mode?)
@normalized_query = post_query.with_implicit_metatags
@@ -134,6 +135,10 @@ module PostSets
end
def show_deleted?
current_user.show_deleted_posts? || has_status_metatag?
end
def has_status_metatag?
post_query.select_metatags("status").any? do |metatag|
metatag.value.downcase.in?(%w[all any active unmoderated modqueue deleted appealed])
end

View File

@@ -65,6 +65,7 @@ class User < ApplicationRecord
no_feedback
requires_verification
is_verified
show_deleted_posts
]
DEFAULT_BLACKLIST = ["guro", "scat", "furry -rating:s"].join("\n")

View File

@@ -47,7 +47,7 @@ class UserPolicy < ApplicationPolicy
blacklisted_tags time_zone per_page custom_style theme
receive_email_notifications always_resize_images
new_post_navigation_layout enable_private_favorites
style_usernames show_deleted_children
style_usernames show_deleted_posts show_deleted_children
disable_categorized_saved_searches disable_tagged_filenames
disable_mobile_gestures enable_safe_mode
enable_desktop_mode disable_post_tooltips

View File

@@ -60,6 +60,7 @@
<%= f.input :style_usernames, :as => :select, :label => "Colored usernames", :hint => "Color users according to their user level", :include_blank => false, :collection => [["Yes", "true"], ["No", "false"]] %>
<%= f.input :new_post_navigation_layout, :as => :select, :label => "Navigation bar position", :include_blank => false, :collection => [["Below", "true"], ["Above", "false"]], :hint => "When browsing pools or posts, place navigation links above or below the image" %>
<%= f.input :show_deleted_posts, as: :select, hint: "Show deleted posts in searches", collection: [["No", "false"], ["Yes", "true"]], include_blank: false %>
<%= f.input :show_deleted_children, :as => :select, :label => "Show deleted children", :hint => "Show thumbnail borders on parent posts even if the children are deleted", :include_blank => false, :collection => [["Yes", "true"], ["No", "false"]] %>
<%= f.input :disable_categorized_saved_searches, :hint => "Don't show dialog box when creating a new saved search", :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
<% if policy(@user).can_enable_private_favorites? %>