fixes #2461: Mod queue comments

This commit is contained in:
r888888888
2015-08-05 13:04:46 -07:00
parent dedca83e7f
commit f66d5c3f02
12 changed files with 125 additions and 16 deletions

View File

@@ -41,6 +41,35 @@
}
});
}
Danbooru.ModQueue.initialize_detailed_rejection_links = function() {
$(".detailed-rejection-link").click(Danbooru.ModQueue.detailed_rejection_dialog)
}
Danbooru.ModQueue.detailed_rejection_dialog = function() {
$("#post_id").val($(this).data("post-id"));
$("#detailed-rejection-dialog").dialog({
width: 500,
buttons: {
"Submit": function() {
var data = $("#detailed-rejection-form").serialize();
$.ajax({
type: "POST",
url: $("#detailed-rejection-form").attr("action"),
data: data,
dataType: "script"
});
$("#detailed-rejection-dialog").dialog("close");
},
"Cancel": function() {
$("#detailed-rejection-dialog").dialog("close");
}
}
});
return false;
}
})();
$(function() {
@@ -48,5 +77,10 @@ $(function() {
Danbooru.ModQueue.initialize_approve_all_button();
Danbooru.ModQueue.initialize_hide_all_button();
Danbooru.ModQueue.initialize_hilights();
Danbooru.ModQueue.initialize_detailed_rejection_links();
}
if ($("#c-posts #a-show").length) {
Danbooru.ModQueue.initialize_detailed_rejection_links();
}
});

View File

@@ -26,7 +26,7 @@ div#c-moderator-post-queues {
section {
float: left;
width: 600px;
width: 800px;
}
&[data-tags~=animated], &[data-file-ext=swf], &[data-file-ext=webm], &[data-file-ext=zip] {

View File

@@ -5,7 +5,7 @@ module Moderator
def create
@post = ::Post.find(params[:post_id])
@post_disapproval = PostDisapproval.create(:post => @post, :user => CurrentUser.user, :reason => params[:reason] || "disinterest")
@post_disapproval = PostDisapproval.create(:post => @post, :user => CurrentUser.user, :reason => params[:reason] || "disinterest", :message => params[:message])
end
end
end

View File

@@ -14,5 +14,6 @@ class DailyMaintenance
PostDisapproval.prune!
ForumSubscription.process_all!
TagAlias.update_cached_post_counts_for_all
PostDisapproval.dmail_messages!
end
end

View File

@@ -4,9 +4,10 @@ class PostDisapproval < ActiveRecord::Base
belongs_to :post
belongs_to :user
validates_uniqueness_of :post_id, :scope => [:user_id], :message => "have already hidden this post"
attr_accessible :post_id, :post, :user_id, :user, :reason
attr_accessible :post_id, :post, :user_id, :user, :reason, :message
validates_inclusion_of :reason, :in => %w(legacy breaks_rules poor_quality disinterest)
scope :with_message, lambda {where("message is not null and message <> ''")}
scope :breaks_rules, lambda {where(:reason => "breaks_rules")}
scope :poor_quality, lambda {where(:reason => "poor_quality")}
scope :disinterest, lambda {where(:reason => ["disinterest", "legacy"])}
@@ -15,6 +16,31 @@ class PostDisapproval < ActiveRecord::Base
PostDisapproval.destroy_all(["created_at < ?", DELETION_THRESHOLD.ago])
end
def self.dmail_messages!
admin = User.admins.first
disapprovals = {}
PostDisapproval.with_message.where("created_at >= ?", 1.year.ago).find_each do |disapproval|
disapprovals[disapproval.user_id] ||= []
disapprovals[disapproval.user_id] << disapproval
end
disapprovals.each do |user_id, list|
user = User.find(user_id)
CurrentUser.scoped(admin, "127.0.0.1") do
message = list.map do |x|
"* post ##{x.post_id}: #{x.message}"
end.join("\n")
Dmail.create_split(
:to_id => user.id,
:title => "Some of your uploads have been critiqued by the moderators",
:body => message
)
end
end
end
def create_downvote
if %w(breaks_rules poor_quality).include?(reason)
PostVote.create(:score => -1, :post_id => post_id)

View File

@@ -41,6 +41,7 @@
| <%= link_to "Breaks Rules", moderator_post_disapproval_path(:post_id => post.id, :reason => "breaks_rules"), :remote => true, :method => :post, :class => "disapprove-link" %>
| <%= link_to "Poor Quality", moderator_post_disapproval_path(:post_id => post.id, :reason => "poor_quality"), :remote => true, :method => :post, :class => "disapprove-link" %>
| <%= link_to "No Interest", moderator_post_disapproval_path(:post_id => post.id, :reason => "disinterest"), :remote => true, :method => :post, :class => "disapprove-link" %>
| <%= link_to "Detailed Rejection", "#", "data-post-id" => post.id, :class => "detailed-rejection-link" %>
</h2>
</li>
<li><strong>Rating</strong>: <%= post.pretty_rating %></li>
@@ -60,16 +61,7 @@
<li><strong>Appeals</strong>: <%= post_appeal_reasons(post) %></li>
<% end %>
<li>
<strong>Hidden</strong>:
<% if post.disapprovals.breaks_rules.exists? %>
(breaks rules: <%= post.disapprovals.breaks_rules.count %>)
<% end %>
<% if post.disapprovals.poor_quality.exists? %>
(poor quality: <%= post.disapprovals.poor_quality.count %>)
<% end %>
<% if post.disapprovals.disinterest.exists? %>
(no interest: <%= post.disapprovals.disinterest.count %>)
<% end %>
<strong>Hidden</strong>: <%= render "post_disapprovals/compact_counts", :disapprovals => post.disapprovals %>
</li>
<li><strong>Tags</strong>: <%= post.tag_string %></li>
</ul>
@@ -82,6 +74,7 @@
</div>
</div>
<%= render "post_disapprovals/detailed_rejection_dialog" %>
<%= render "posts/partials/common/secondary_links" %>
<% content_for(:page_title) do %>

View File

@@ -0,0 +1,17 @@
<% if disapprovals.count > 0 %>
<% if disapprovals.breaks_rules.count > 0 %>
(breaks rules: <%= disapprovals.breaks_rules.count %>)
<% end %>
<% if disapprovals.poor_quality.count > 0 %>
(poor quality: <%= disapprovals.poor_quality.count %>)
<% end %>
<% if disapprovals.disinterest.count > 0 %>
(no interest: <%= disapprovals.disinterest.count %>)
<% end %>
<% if disapprovals.with_message.any? %>
(messages: <%= disapprovals.disinterest.with_message.map(&:message).to_sentence %>)
<% end %>
<% end %>

View File

@@ -13,5 +13,9 @@
<% if disapprovals.disinterest.count > 0 %>
<%= disapprovals.disinterest.count %> did not like the post enough to approve it.
<% end %>
<% if disapprovals.with_message.any? %>
Messages: <%= disapprovals.with_message.map(&:message).to_sentence %>
<% end %>
</p>
<% end %>

View File

@@ -0,0 +1,17 @@
<div id="detailed-rejection-dialog" title="Detailed Rejection" style="display: none;">
<%= form_tag(moderator_post_disapproval_path, :class => "simple_form", :id => "detailed-rejection-form") do %>
<%= hidden_field_tag "post_id", "x" %>
<p>You can supply a short message to the uploader explaining why you rejected this upload.</p>
<div class="input">
<label>Reason</label>
<%= select_tag "reason", options_for_select([["Breaks Rules", "breaks_rules"], ["Poor Quality", "poor_quality"], ["No Interest", "disinterest"]]) %>
</div>
<div class="input">
<label>Message</label>
<%= text_field_tag "message" %>
</div>
<% end %>
</div>

View File

@@ -43,7 +43,9 @@
<% end %>
<%= link_to "Breaks Rules", moderator_post_disapproval_path(:post_id => post.id, :reason => "breaks_rules"), :method => :post, :remote => true, :class => "btn" %> |
<%= link_to "Poor Quality", moderator_post_disapproval_path(:post_id => post.id, :reason => "poor_quality"), :method => :post, :remote => true, :class => "btn" %> |
<%= link_to "No Interest", moderator_post_disapproval_path(:post_id => post.id, :reason => "disinterest"), :method => :post, :remote => true, :class => "btn" %>
<%= link_to "No Interest", moderator_post_disapproval_path(:post_id => post.id, :reason => "disinterest"), :method => :post, :remote => true, :class => "btn" %> |
<%= link_to "Detailed Rejection", "#", "data-post-id" => post.id, :class => "detailed-rejection-link btn" %>
</div>
<% end %>
</div>
@@ -76,3 +78,5 @@
<span style="display: none;">Loading...</span>
</div>
<% end %>
<%= render "post_disapprovals/detailed_rejection_dialog" %>

View File

@@ -0,0 +1,5 @@
class AddMessageToDisapprovals < ActiveRecord::Migration
def change
add_column :post_disapprovals, :message, :text
end
end

View File

@@ -2576,7 +2576,8 @@ CREATE TABLE post_disapprovals (
post_id integer NOT NULL,
created_at timestamp without time zone,
updated_at timestamp without time zone,
reason character varying(255) DEFAULT 'legacy'::character varying
reason character varying(255) DEFAULT 'legacy'::character varying,
message text
);
@@ -3166,7 +3167,10 @@ CREATE TABLE users (
comment_threshold integer DEFAULT (-1) NOT NULL,
default_image_size character varying(255) DEFAULT 'large'::character varying NOT NULL,
favorite_tags text,
blacklisted_tags text,
blacklisted_tags text DEFAULT 'spoilers
guro
scat
furry -rating:s'::text,
time_zone character varying(255) DEFAULT 'Eastern Time (US & Canada)'::character varying NOT NULL,
bcrypt_password_hash text,
per_page integer DEFAULT 20 NOT NULL,
@@ -7268,3 +7272,7 @@ INSERT INTO schema_migrations (version) VALUES ('20150705014135');
INSERT INTO schema_migrations (version) VALUES ('20150721214646');
INSERT INTO schema_migrations (version) VALUES ('20150728170433');
INSERT INTO schema_migrations (version) VALUES ('20150805010245');