diff --git a/app/controllers/moderator/post/disapprovals_controller.rb b/app/controllers/moderator/post/disapprovals_controller.rb index cc23ad7d1..0c8ccf9a2 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) + @post_disapproval = PostDisapproval.create(:post => @post, :user => CurrentUser.user, :reason => params[:reason] || "disinterest") end end end diff --git a/app/models/post_disapproval.rb b/app/models/post_disapproval.rb index 82ece2a24..d081d8424 100644 --- a/app/models/post_disapproval.rb +++ b/app/models/post_disapproval.rb @@ -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 diff --git a/app/views/moderator/post/queues/show.html.erb b/app/views/moderator/post/queues/show.html.erb index 06cc66e47..29337d62b 100644 --- a/app/views/moderator/post/queues/show.html.erb +++ b/app/views/moderator/post/queues/show.html.erb @@ -21,7 +21,9 @@ <% end %>

+ <% @posts.each do |post| %> @@ -32,7 +34,14 @@
diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb index db8e18b5e..c67b394ed 100644 --- a/app/views/posts/partials/show/_notices.html.erb +++ b/app/views/posts/partials/show/_notices.html.erb @@ -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" %> <% end %> diff --git a/db/migrate/20150721214646_add_reason_to_post_disapprovals.rb b/db/migrate/20150721214646_add_reason_to_post_disapprovals.rb new file mode 100644 index 000000000..f85b5e0ad --- /dev/null +++ b/db/migrate/20150721214646_add_reason_to_post_disapprovals.rb @@ -0,0 +1,5 @@ +class AddReasonToPostDisapprovals < ActiveRecord::Migration + def change + add_column :post_disapprovals, :reason, :string, :default => "legacy" + end +end diff --git a/db/structure.sql b/db/structure.sql index 2c96b2795..02c6515ec 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -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'); +