forked from e621ng/e621ng
[Cleanup] Remove modqueue random
This commit is contained in:
parent
b50e378600
commit
dd8aa8199b
@ -1,14 +1,11 @@
|
||||
module Moderator
|
||||
module Post
|
||||
class QueuesController < ApplicationController
|
||||
RANDOM_COUNT = 12
|
||||
|
||||
respond_to :html, :json
|
||||
before_action :approver_only
|
||||
skip_before_action :api_check
|
||||
|
||||
def show
|
||||
|
||||
if params[:per_page]
|
||||
cookies.permanent["mq_per_page"] = params[:per_page]
|
||||
end
|
||||
@ -23,23 +20,6 @@ module Moderator
|
||||
respond_with(@posts)
|
||||
end
|
||||
|
||||
def random
|
||||
::Post.without_timeout do
|
||||
@posts = ::Post.includes(:disapprovals, :uploader).order("posts.id asc").pending_or_flagged.available_for_moderation(false).reorder("random()").limit(RANDOM_COUNT)
|
||||
@posts.each # hack to force rails to eager load
|
||||
|
||||
if @posts.empty?
|
||||
flash[:notice] = "Nothing left to moderate!"
|
||||
redirect_to(params[:return_to] || posts_path)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
respond_with(@posts)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def per_page
|
||||
cookies["mq_per_page"] || params[:per_page] || 25
|
||||
end
|
||||
|
@ -349,7 +349,7 @@ Autocomplete.normal_source = function(term, resp) {
|
||||
Autocomplete.static_metatags = {
|
||||
order: Autocomplete.ORDER_METATAGS,
|
||||
status: [
|
||||
"any", "deleted", "active", "pending", "flagged", "modqueue", "unmoderated"
|
||||
"any", "deleted", "active", "pending", "flagged", "modqueue"
|
||||
],
|
||||
rating: [
|
||||
"safe", "questionable", "explicit"
|
||||
|
@ -146,8 +146,6 @@ class PostQueryBuilder
|
||||
relation = relation.where("posts.is_deleted = TRUE")
|
||||
elsif q[:status] == "active"
|
||||
relation = relation.where("posts.is_pending = FALSE AND posts.is_deleted = 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"
|
||||
|
@ -1647,12 +1647,6 @@ class Post < ApplicationRecord
|
||||
where("uploader_id = ?", user_id)
|
||||
end
|
||||
|
||||
def available_for_moderation(hidden = false, user = CurrentUser.user)
|
||||
return none if user.is_anonymous?
|
||||
|
||||
where.not(uploader: user)
|
||||
end
|
||||
|
||||
def sql_raw_tag_match(tag)
|
||||
where("posts.tag_index @@ to_tsquery('danbooru', E?)", tag.to_escaped_for_tsquery)
|
||||
end
|
||||
|
@ -1,34 +0,0 @@
|
||||
<div id="c-moderator-post-queues">
|
||||
<div id="a-random">
|
||||
<div>
|
||||
<h1>Moderation Queue</h1>
|
||||
|
||||
<div id="moderation-guideline">
|
||||
<p>Here are twelve random posts that are up for moderation. See if any of them are worth approving. Once you finish processing all of them you will be taken to the previous URL (<%= params[:return_to] %>).</p>
|
||||
|
||||
<h1>Deletion Guidelines</h1>
|
||||
|
||||
<%= render "desc" %>
|
||||
|
||||
</div>
|
||||
|
||||
<%= render "posts/partials/common/inline_blacklist" %>
|
||||
|
||||
<% @posts.each do |post| %>
|
||||
<%= render "post", post: post %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "post_disapprovals/detailed_rejection_dialog" %>
|
||||
<%= render "posts/partials/common/secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Mod Queue
|
||||
<% end %>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
<meta name="random-mode" content="1">
|
||||
<meta name="return-to" content="<%= params[:return_to] %>">
|
||||
<% end %>
|
@ -34,11 +34,7 @@ Rails.application.routes.draw do
|
||||
resources :invitations, :only => [:new, :create, :index]
|
||||
resource :tag, :only => [:edit, :update]
|
||||
namespace :post do
|
||||
resource :queue, :only => [:show] do
|
||||
member do
|
||||
get :random
|
||||
end
|
||||
end
|
||||
resource :queue, :only => [:show]
|
||||
resource :approval, :only => [:create, :destroy]
|
||||
resources :disapprovals, :only => [:create, :index]
|
||||
resources :posts, :only => [:delete, :undelete, :expunge, :confirm_delete] do
|
||||
|
@ -19,35 +19,6 @@ class PostDisapprovalTest < ActiveSupport::TestCase
|
||||
@post_2 = FactoryBot.create(:post, :is_pending => true)
|
||||
end
|
||||
|
||||
context "made by alice" do
|
||||
setup do
|
||||
@disapproval = PostDisapproval.create(:user => @alice, :post => @post_1)
|
||||
end
|
||||
|
||||
context "when the current user is alice" do
|
||||
setup do
|
||||
CurrentUser.user = @alice
|
||||
end
|
||||
|
||||
should "remove the associated post from alice's moderation queue" do
|
||||
assert(!Post.available_for_moderation(false).map(&:id).include?(@post_1.id))
|
||||
assert(Post.available_for_moderation(false).map(&:id).include?(@post_2.id))
|
||||
end
|
||||
end
|
||||
|
||||
context "when the current user is brittony" do
|
||||
setup do
|
||||
@brittony = FactoryBot.create(:moderator_user)
|
||||
CurrentUser.user = @brittony
|
||||
end
|
||||
|
||||
should "not remove the associated post from brittony's moderation queue" do
|
||||
assert(Post.available_for_moderation(false).map(&:id).include?(@post_1.id))
|
||||
assert(Post.available_for_moderation(false).map(&:id).include?(@post_2.id))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "#search" do
|
||||
should "work" do
|
||||
disapproval1 = FactoryBot.create(:post_disapproval, user: @alice, post: @post_1, reason: "breaks_rules")
|
||||
|
Loading…
Reference in New Issue
Block a user