From 43377e3a8294e8ba399b6e8a3daabe836e87522c Mon Sep 17 00:00:00 2001 From: r888888888 Date: Thu, 23 Jul 2015 14:29:18 -0700 Subject: [PATCH] fixes #2447: Display disapproval counts in status bar to uploader and approvers --- app/logical/daily_maintenance.rb | 1 + app/models/post_disapproval.rb | 4 +++- app/views/post_disapprovals/_counts.html.erb | 13 +++++++++++++ .../posts/partials/show/_notices.html.erb | 18 ++++++------------ 4 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 app/views/post_disapprovals/_counts.html.erb diff --git a/app/logical/daily_maintenance.rb b/app/logical/daily_maintenance.rb index 3440d9105..f84322aa4 100644 --- a/app/logical/daily_maintenance.rb +++ b/app/logical/daily_maintenance.rb @@ -11,6 +11,7 @@ class DailyMaintenance # UserUploadClamper.new.clamp_all! TagSubscription.process_all ApiCacheGenerator.new.generate_tag_cache + PostDisapproval.prune! ForumSubscription.process_all! TagAlias.update_cached_post_counts_for_all end diff --git a/app/models/post_disapproval.rb b/app/models/post_disapproval.rb index d081d8424..12ba96e06 100644 --- a/app/models/post_disapproval.rb +++ b/app/models/post_disapproval.rb @@ -1,4 +1,6 @@ class PostDisapproval < ActiveRecord::Base + DELETION_THRESHOLD = 1.month + belongs_to :post belongs_to :user validates_uniqueness_of :post_id, :scope => [:user_id], :message => "have already hidden this post" @@ -10,7 +12,7 @@ class PostDisapproval < ActiveRecord::Base scope :disinterest, lambda {where(:reason => ["disinterest", "legacy"])} def self.prune! - joins(:post).where("posts.is_pending = FALSE AND posts.is_flagged = FALSE").each do |post_disapproval| + PostDisapproval.joins(:post).where("posts.is_pending = FALSE AND posts.is_flagged = FALSE and post_disapprovals.created_at < ?", DELETION_THRESHOLD.ago).each do |post_disapproval| post_disapproval.destroy end end diff --git a/app/views/post_disapprovals/_counts.html.erb b/app/views/post_disapprovals/_counts.html.erb new file mode 100644 index 000000000..f7843db0e --- /dev/null +++ b/app/views/post_disapprovals/_counts.html.erb @@ -0,0 +1,13 @@ +It has been reviewed by <%= pluralize disapprovals.count, "moderator" %>. + +<% if disapprovals.breaks_rules.count > 0 %> + <%= disapprovals.breaks_rules.count %> believe it breaks the rules. +<% end %> + +<% if disapprovals.poor_quality.count > 0 %> + <%= disapprovals.poor_quality.count %> believe it has poor quality. +<% end %> + +<% if disapprovals.disinterest.count > 0 %> + <%= disapprovals.disinterest.count %> did not like the post enough to approve it. +<% end %> diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb index b88aef857..dce52ec2c 100644 --- a/app/views/posts/partials/show/_notices.html.erb +++ b/app/views/posts/partials/show/_notices.html.erb @@ -18,7 +18,11 @@

This post was deleted for the following reasons:

<%= post_flag_reasons(post) %> <% else %> - This post was deleted +

This post was deleted

+ <% end %> + + <% if post.disapprovals.count > 0 %> +

<%= render "post_disapprovals/counts", :disapprovals => post.disapprovals %>

<% end %> <% end %> @@ -27,17 +31,7 @@
<% if post.is_pending? %> This post is pending approval. - It has been reviewed by <%= pluralize post.disapprovals.count, "moderator" %>. - <% if post.disapprovals.breaks_rules.count > 0 %> - <%= post.disapprovals.breaks_rules.count %> believe it breaks the rules. - <% end %> - <% if post.disapprovals.poor_quality.count > 0 %> - <%= post.disapprovals.poor_quality.count %> believe it has poor quality. - <% end %> - <% if post.disapprovals.disinterest.count > 0 %> - <%= post.disapprovals.disinterest.count %> did not like the post enough to approve it. - <% end %> - + <%= render "post_disapprovals/counts", :disapprovals => post.disapprovals %> (<%= link_to "learn more", wiki_pages_path(:title => "about:mod_queue") %>) <% else %> This post was flagged and is pending approval (<%= link_to "learn more", wiki_pages_path(:title => "about:mod_queue") %>)