From f66d5c3f022f2a53bc392cdd3dfd7c2d20772666 Mon Sep 17 00:00:00 2001
From: r888888888
Date: Wed, 5 Aug 2015 13:04:46 -0700
Subject: [PATCH] fixes #2461: Mod queue comments
---
app/assets/javascripts/mod_queue.js | 34 +++++++++++++++++++
.../stylesheets/specific/mod_queue.css.scss | 2 +-
.../moderator/post/disapprovals_controller.rb | 2 +-
app/logical/daily_maintenance.rb | 1 +
app/models/post_disapproval.rb | 28 ++++++++++++++-
app/views/moderator/post/queues/show.html.erb | 13 ++-----
.../_compact_counts.html.erb | 17 ++++++++++
app/views/post_disapprovals/_counts.html.erb | 4 +++
.../_detailed_rejection_dialog.html.erb | 17 ++++++++++
.../posts/partials/show/_notices.html.erb | 6 +++-
...50805010245_add_message_to_disapprovals.rb | 5 +++
db/structure.sql | 12 +++++--
12 files changed, 125 insertions(+), 16 deletions(-)
create mode 100644 app/views/post_disapprovals/_compact_counts.html.erb
create mode 100644 app/views/post_disapprovals/_detailed_rejection_dialog.html.erb
create mode 100644 db/migrate/20150805010245_add_message_to_disapprovals.rb
diff --git a/app/assets/javascripts/mod_queue.js b/app/assets/javascripts/mod_queue.js
index 95382c5e6..0d541aaf7 100644
--- a/app/assets/javascripts/mod_queue.js
+++ b/app/assets/javascripts/mod_queue.js
@@ -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();
}
});
diff --git a/app/assets/stylesheets/specific/mod_queue.css.scss b/app/assets/stylesheets/specific/mod_queue.css.scss
index f640089bb..96e529d62 100644
--- a/app/assets/stylesheets/specific/mod_queue.css.scss
+++ b/app/assets/stylesheets/specific/mod_queue.css.scss
@@ -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] {
diff --git a/app/controllers/moderator/post/disapprovals_controller.rb b/app/controllers/moderator/post/disapprovals_controller.rb
index 0c8ccf9a2..621691fa7 100644
--- a/app/controllers/moderator/post/disapprovals_controller.rb
+++ b/app/controllers/moderator/post/disapprovals_controller.rb
@@ -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
diff --git a/app/logical/daily_maintenance.rb b/app/logical/daily_maintenance.rb
index f84322aa4..5652f185d 100644
--- a/app/logical/daily_maintenance.rb
+++ b/app/logical/daily_maintenance.rb
@@ -14,5 +14,6 @@ class DailyMaintenance
PostDisapproval.prune!
ForumSubscription.process_all!
TagAlias.update_cached_post_counts_for_all
+ PostDisapproval.dmail_messages!
end
end
diff --git a/app/models/post_disapproval.rb b/app/models/post_disapproval.rb
index 0543eee62..97611817c 100644
--- a/app/models/post_disapproval.rb
+++ b/app/models/post_disapproval.rb
@@ -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)
diff --git a/app/views/moderator/post/queues/show.html.erb b/app/views/moderator/post/queues/show.html.erb
index ffc9a216b..031c9fef7 100644
--- a/app/views/moderator/post/queues/show.html.erb
+++ b/app/views/moderator/post/queues/show.html.erb
@@ -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" %>
Rating : <%= post.pretty_rating %>
@@ -60,16 +61,7 @@
Appeals : <%= post_appeal_reasons(post) %>
<% end %>
- Hidden :
- <% 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 %>
+ Hidden : <%= render "post_disapprovals/compact_counts", :disapprovals => post.disapprovals %>
Tags : <%= post.tag_string %>
@@ -82,6 +74,7 @@
+<%= render "post_disapprovals/detailed_rejection_dialog" %>
<%= render "posts/partials/common/secondary_links" %>
<% content_for(:page_title) do %>
diff --git a/app/views/post_disapprovals/_compact_counts.html.erb b/app/views/post_disapprovals/_compact_counts.html.erb
new file mode 100644
index 000000000..e76112a45
--- /dev/null
+++ b/app/views/post_disapprovals/_compact_counts.html.erb
@@ -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 %>
\ No newline at end of file
diff --git a/app/views/post_disapprovals/_counts.html.erb b/app/views/post_disapprovals/_counts.html.erb
index 289006aaa..ec046e6fc 100644
--- a/app/views/post_disapprovals/_counts.html.erb
+++ b/app/views/post_disapprovals/_counts.html.erb
@@ -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 %>
<% end %>
\ No newline at end of file
diff --git a/app/views/post_disapprovals/_detailed_rejection_dialog.html.erb b/app/views/post_disapprovals/_detailed_rejection_dialog.html.erb
new file mode 100644
index 000000000..09b95feac
--- /dev/null
+++ b/app/views/post_disapprovals/_detailed_rejection_dialog.html.erb
@@ -0,0 +1,17 @@
+
+ <%= form_tag(moderator_post_disapproval_path, :class => "simple_form", :id => "detailed-rejection-form") do %>
+ <%= hidden_field_tag "post_id", "x" %>
+
+
You can supply a short message to the uploader explaining why you rejected this upload.
+
+
+ Reason
+ <%= select_tag "reason", options_for_select([["Breaks Rules", "breaks_rules"], ["Poor Quality", "poor_quality"], ["No Interest", "disinterest"]]) %>
+
+
+
+ Message
+ <%= text_field_tag "message" %>
+
+ <% end %>
+
diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb
index 19daf1d27..7433ef830 100644
--- a/app/views/posts/partials/show/_notices.html.erb
+++ b/app/views/posts/partials/show/_notices.html.erb
@@ -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" %>
+
<% end %>
@@ -76,3 +78,5 @@
Loading...
<% end %>
+
+<%= render "post_disapprovals/detailed_rejection_dialog" %>
\ No newline at end of file
diff --git a/db/migrate/20150805010245_add_message_to_disapprovals.rb b/db/migrate/20150805010245_add_message_to_disapprovals.rb
new file mode 100644
index 000000000..023031c45
--- /dev/null
+++ b/db/migrate/20150805010245_add_message_to_disapprovals.rb
@@ -0,0 +1,5 @@
+class AddMessageToDisapprovals < ActiveRecord::Migration
+ def change
+ add_column :post_disapprovals, :message, :text
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 02c6515ec..b231fbf3e 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -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');
+