search: add status:modqueue, status:unmoderated metatags.
* status:modqueue = ~status:pending ~status:flagged * status:unmoderated = status:modqueue -user:self -approver:self -disapproval:any
This commit is contained in:
@@ -399,7 +399,7 @@ Autocomplete.static_metatags = {
|
||||
"custom"
|
||||
].concat(<%= TagCategory.short_name_list.map {|category| [category + "tags", category + "tags_asc"]}.flatten %>),
|
||||
status: [
|
||||
"any", "deleted", "active", "pending", "flagged", "banned"
|
||||
"any", "deleted", "active", "pending", "flagged", "banned", "modqueue", "unmoderated"
|
||||
],
|
||||
rating: [
|
||||
"safe", "questionable", "explicit"
|
||||
|
||||
@@ -131,18 +131,24 @@ class PostQueryBuilder
|
||||
relation = relation.where("posts.is_pending = TRUE")
|
||||
elsif q[:status] == "flagged"
|
||||
relation = relation.where("posts.is_flagged = TRUE")
|
||||
elsif q[:status] == "modqueue"
|
||||
relation = relation.where("posts.is_pending = TRUE OR posts.is_flagged = TRUE")
|
||||
elsif q[:status] == "deleted"
|
||||
relation = relation.where("posts.is_deleted = TRUE")
|
||||
elsif q[:status] == "banned"
|
||||
relation = relation.where("posts.is_banned = TRUE")
|
||||
elsif q[:status] == "active"
|
||||
relation = relation.where("posts.is_pending = FALSE AND posts.is_deleted = FALSE AND posts.is_banned = FALSE AND posts.is_flagged = FALSE")
|
||||
elsif q[:status] == "unmoderated"
|
||||
relation = relation.merge(Post.pending_or_flagged.available_for_moderation)
|
||||
elsif q[:status] == "all" || q[:status] == "any"
|
||||
# do nothing
|
||||
elsif q[:status_neg] == "pending"
|
||||
relation = relation.where("posts.is_pending = FALSE")
|
||||
elsif q[:status_neg] == "flagged"
|
||||
relation = relation.where("posts.is_flagged = FALSE")
|
||||
elsif q[:status_neg] == "modqueue"
|
||||
relation = relation.where("posts.is_pending = FALSE AND posts.is_flagged = FALSE")
|
||||
elsif q[:status_neg] == "deleted"
|
||||
relation = relation.where("posts.is_deleted = FALSE")
|
||||
elsif q[:status_neg] == "banned"
|
||||
|
||||
@@ -1645,7 +1645,9 @@ class Post < ApplicationRecord
|
||||
where("uploader_id = ?", user_id)
|
||||
end
|
||||
|
||||
def available_for_moderation(hidden, user = CurrentUser.user)
|
||||
def available_for_moderation(hidden = false, user = CurrentUser.user)
|
||||
return none if user.is_anonymous?
|
||||
|
||||
approved_posts = user.post_approvals.select(:post_id)
|
||||
disapproved_posts = user.post_disapprovals.select(:post_id)
|
||||
|
||||
|
||||
@@ -2130,6 +2130,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
banned = FactoryBot.create(:post, is_banned: true)
|
||||
all = [banned, deleted, flagged, pending]
|
||||
|
||||
assert_tag_match([flagged, pending], "status:modqueue")
|
||||
assert_tag_match([pending], "status:pending")
|
||||
assert_tag_match([flagged], "status:flagged")
|
||||
assert_tag_match([deleted], "status:deleted")
|
||||
@@ -2138,6 +2139,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
assert_tag_match(all, "status:any")
|
||||
assert_tag_match(all, "status:all")
|
||||
|
||||
assert_tag_match(all - [flagged, pending], "-status:modqueue")
|
||||
assert_tag_match(all - [pending], "-status:pending")
|
||||
assert_tag_match(all - [flagged], "-status:flagged")
|
||||
assert_tag_match(all - [deleted], "-status:deleted")
|
||||
@@ -2145,6 +2147,17 @@ class PostTest < ActiveSupport::TestCase
|
||||
assert_tag_match(all, "-status:active")
|
||||
end
|
||||
|
||||
should "return posts for the status:unmoderated metatag" do
|
||||
flagged = FactoryBot.create(:post, is_flagged: true)
|
||||
pending = FactoryBot.create(:post, is_pending: true)
|
||||
disapproved = FactoryBot.create(:post, is_pending: true)
|
||||
|
||||
FactoryBot.create(:post_flag, post: flagged)
|
||||
FactoryBot.create(:post_disapproval, post: disapproved, reason: "disinterest")
|
||||
|
||||
assert_tag_match([pending, flagged], "status:unmoderated")
|
||||
end
|
||||
|
||||
should "respect the 'Deleted post filter' option when using the status:banned metatag" do
|
||||
deleted = FactoryBot.create(:post, is_deleted: true, is_banned: true)
|
||||
undeleted = FactoryBot.create(:post, is_banned: true)
|
||||
|
||||
Reference in New Issue
Block a user