diff --git a/app/assets/javascripts/mod_queue.js b/app/assets/javascripts/mod_queue.js index 0d541aaf7..a2da092b6 100644 --- a/app/assets/javascripts/mod_queue.js +++ b/app/assets/javascripts/mod_queue.js @@ -1,6 +1,18 @@ (function() { Danbooru.ModQueue = {}; + Danbooru.ModQueue.processed = 0; + + Danbooru.ModQueue.increment_processed = function() { + if (Danbooru.meta("random-mode") === "1") { + Danbooru.ModQueue.processed += 1; + + if (Danbooru.ModQueue.processed === 5) { + window.location = Danbooru.meta("return-to"); + } + } + } + Danbooru.ModQueue.initialize_approve_all_button = function() { $("#approve-all-button").click(function(e) { if (!confirm("Are you sure you want to approve every post on this page?")) { diff --git a/app/controllers/moderator/post/approvals_controller.rb b/app/controllers/moderator/post/approvals_controller.rb index 768cbf200..ec2cf8f3c 100644 --- a/app/controllers/moderator/post/approvals_controller.rb +++ b/app/controllers/moderator/post/approvals_controller.rb @@ -4,6 +4,7 @@ module Moderator before_filter :post_approvers_only def create + cookies[:moderated] = Time.now.to_i @post = ::Post.find(params[:post_id]) if @post.is_deleted? || @post.is_flagged? || @post.is_pending? @post.approve! diff --git a/app/controllers/moderator/post/disapprovals_controller.rb b/app/controllers/moderator/post/disapprovals_controller.rb index 621691fa7..93018f274 100644 --- a/app/controllers/moderator/post/disapprovals_controller.rb +++ b/app/controllers/moderator/post/disapprovals_controller.rb @@ -4,6 +4,7 @@ module Moderator before_filter :post_approvers_only def create + cookies[:moderated] = Time.now.to_i @post = ::Post.find(params[:post_id]) @post_disapproval = PostDisapproval.create(:post => @post, :user => CurrentUser.user, :reason => params[:reason] || "disinterest", :message => params[:message]) end diff --git a/app/controllers/moderator/post/queues_controller.rb b/app/controllers/moderator/post/queues_controller.rb index c305682a2..9763fa31c 100644 --- a/app/controllers/moderator/post/queues_controller.rb +++ b/app/controllers/moderator/post/queues_controller.rb @@ -5,6 +5,8 @@ module Moderator before_filter :post_approvers_only def show + cookies[:moderated] = Time.now.to_i + if params[:per_page] cookies.permanent["mq_per_page"] = params[:per_page] end @@ -16,8 +18,22 @@ module Moderator respond_with(@posts) end + def random + cookies[:moderated] = Time.now.to_i + + ::Post.without_timeout do + @posts = ::Post.order("posts.id asc").pending_or_flagged.available_for_moderation(false).reorder("random()").limit(5) + @posts.each # hack to force rails to eager load + end + + respond_with(@posts) + end + protected + def get_posts + end + def per_page cookies["mq_per_page"] || params[:per_page] || 25 end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 5bae722f0..6213f10fd 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -27,6 +27,12 @@ class PostsController < ApplicationController end def show + if CurrentUser.is_janitor? && (cookies[:moderated].blank? || Time.at(cookies[:moderated].to_i) < 1.day.ago) + flash[:notice] = "You haven't moderated any posts recently. Consider checking the queue." + #redirect_to(random_moderator_post_queue_path(:return_to => request.original_url)) + #return + end + @post = Post.find(params[:id]) @post_flag = PostFlag.new(:post_id => @post.id) @post_appeal = PostAppeal.new(:post_id => @post.id) diff --git a/app/views/moderator/post/approvals/create.js.erb b/app/views/moderator/post/approvals/create.js.erb index b0d49e1ad..515a6bcc4 100644 --- a/app/views/moderator/post/approvals/create.js.erb +++ b/app/views/moderator/post/approvals/create.js.erb @@ -13,4 +13,6 @@ $("#pending-approval-notice").hide(); $("#c-moderator-post-queues #post-<%= @post.id %>").hide(); Danbooru.notice("Post was approved"); +Danbooru.ModQueue.increment_processed(); + <% end %> diff --git a/app/views/moderator/post/disapprovals/create.js.erb b/app/views/moderator/post/disapprovals/create.js.erb index 10ad0c7bf..b31c2beaf 100644 --- a/app/views/moderator/post/disapprovals/create.js.erb +++ b/app/views/moderator/post/disapprovals/create.js.erb @@ -12,4 +12,6 @@ $("#pending-approval-notice").hide(); $("#c-moderator-post-queues #post-<%= @post.id %>").remove(); Danbooru.notice("Post was hidden"); +Danbooru.ModQueue.increment_processed(); + <% end %> diff --git a/app/views/moderator/post/queues/random.html.erb b/app/views/moderator/post/queues/random.html.erb new file mode 100644 index 000000000..d5fc2d463 --- /dev/null +++ b/app/views/moderator/post/queues/random.html.erb @@ -0,0 +1,70 @@ +
Here are five 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] %>).
+ ++ As a general rule, you should only approve of posts that you personally like. Posts that are not approved in three days will be automatically deleted. Posts with score -3 or lower are marked red. Posts with score 3 or higher are marked green. Posts with the duplicate tag are marked in yellow. +
+