fixes #2446
This commit is contained in:
@@ -5,7 +5,7 @@ module Moderator
|
||||
|
||||
def create
|
||||
@post = ::Post.find(params[:post_id])
|
||||
@post_disapproval = PostDisapproval.create(:post => @post, :user => CurrentUser.user)
|
||||
@post_disapproval = PostDisapproval.create(:post => @post, :user => CurrentUser.user, :reason => params[:reason] || "disinterest")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,11 +2,22 @@ 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
|
||||
attr_accessible :post_id, :post, :user_id, :user, :reason
|
||||
validates_inclusion_of :reason, :in => %w(legacy breaks_rules poor_quality disinterest)
|
||||
|
||||
scope :breaks_rules, lambda {where(:reason => "breaks_rules")}
|
||||
scope :poor_quality, lambda {where(:reason => "poor_quality")}
|
||||
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|
|
||||
post_disapproval.destroy
|
||||
end
|
||||
end
|
||||
|
||||
def create_downvote
|
||||
if %w(breaks_rules poor_quality).include?(reason)
|
||||
PostVote.create(:score => -1, :post_id => post_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<!--
|
||||
<p><%= button_tag "Approve all", :id => "approve-all-button" %><%= button_tag "Hide all", :id => "hide-all-button" %></p>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<% @posts.each do |post| %>
|
||||
@@ -32,7 +34,14 @@
|
||||
|
||||
<section>
|
||||
<ul>
|
||||
<li><h2><%= link_to "Approve", moderator_post_approval_path(:post_id => post.id), :remote => true, :method => :post, :class => "approve-link" %> | <%= link_to "Hide", moderator_post_disapproval_path(:post_id => post.id), :remote => true, :method => :post, :class => "disapprove-link" %></h2></li>
|
||||
<li>
|
||||
<h2>
|
||||
<%= link_to "Approve", moderator_post_approval_path(:post_id => post.id), :remote => true, :method => :post, :class => "approve-link" %>
|
||||
| <%= 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" %>
|
||||
</h2>
|
||||
</li>
|
||||
<li><strong>Rating</strong>: <%= post.pretty_rating %></li>
|
||||
<li><strong>Score</strong>: <%= post.score %></li>
|
||||
<li>
|
||||
@@ -49,7 +58,18 @@
|
||||
<% if (post.is_flagged? || post.is_deleted?) && post.appeals.any? %>
|
||||
<li><strong>Appeals</strong>: <%= post_appeal_reasons(post) %></li>
|
||||
<% end %>
|
||||
<li><strong>Hidden</strong>: <%= post.disapprovals.count %></li>
|
||||
<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 %>
|
||||
</li>
|
||||
<li><strong>Tags</strong>: <%= post.tag_string %></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
<% unless post.is_status_locked? %>
|
||||
<%= link_to "Approve", moderator_post_approval_path(:post_id => post.id), :method => :post, :remote => true, :class => "btn" %> |
|
||||
<% end %>
|
||||
<%= link_to "Hide from queue", moderator_post_disapproval_path(:post_id => post.id), :method => :post, :remote => true, :class => "btn" %>
|
||||
<%= 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" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddReasonToPostDisapprovals < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :post_disapprovals, :reason, :string, :default => "legacy"
|
||||
end
|
||||
end
|
||||
@@ -2575,7 +2575,8 @@ CREATE TABLE post_disapprovals (
|
||||
user_id integer NOT NULL,
|
||||
post_id integer NOT NULL,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone
|
||||
updated_at timestamp without time zone,
|
||||
reason character varying(255) DEFAULT 'legacy'::character varying
|
||||
);
|
||||
|
||||
|
||||
@@ -7265,3 +7266,5 @@ INSERT INTO schema_migrations (version) VALUES ('20150629235905');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150705014135');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150721214646');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user