updated mod queue

This commit is contained in:
albert
2011-10-26 18:16:29 -04:00
parent a536a2699b
commit 0229dbc711
9 changed files with 50 additions and 14 deletions

View File

@@ -41,7 +41,7 @@ class Post < ActiveRecord::Base
scope :commented_before, lambda {|date| where("last_commented_at < ?", date).order("last_commented_at DESC")}
scope :has_notes, where("last_noted_at is not null")
scope :for_user, lambda {|user_id| where(["uploader_id = ?", user_id])}
scope :available_for_moderation, lambda {where(["id NOT IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
scope :available_for_moderation, lambda {|hidden| hidden.present? ? where(["id NOT IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id]) : where(["id NOT IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
scope :hidden_from_moderation, lambda {where(["id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
scope :tag_match, lambda {|query| Post.tag_match_helper(query)}
scope :exact_tag_match, lambda {|query| Post.exact_tag_match_helper(query)}

View File

@@ -1,7 +1,7 @@
class PostDisapproval < ActiveRecord::Base
belongs_to :post
belongs_to :user
validates_uniqueness_of :post_id, :scope => [:user_id]
validates_uniqueness_of :post_id, :scope => [:user_id], :message => "have already hidden this post"
def self.prune!
joins(:post).where("posts.is_pending = FALSE AND posts.is_flagged = FALSE").each do |post_disapproval|