This commit is contained in:
albert
2011-03-29 13:56:30 -04:00
parent f9c961cdc6
commit 5856b105f5
30 changed files with 236 additions and 1733 deletions

View File

@@ -5,7 +5,7 @@ class PostAppeal < ActiveRecord::Base
belongs_to :post
validates_presence_of :reason, :creator_id, :creator_ip_addr
validate :validate_post_is_inactive
validate :creator_is_not_limited
validate :validate_creator_is_not_limited
before_validation :initialize_creator, :on => :create
validates_uniqueness_of :creator_id, :scope => :post_id
scope :for_user, lambda {|user_id| where(["creator_id = ?", user_id])}

View File

@@ -4,10 +4,15 @@ class PostFlag < ActiveRecord::Base
belongs_to :creator, :class_name => "User"
belongs_to :post
validates_presence_of :reason, :creator_id, :creator_ip_addr
validate :creator_is_not_limited
validate :validate_creator_is_not_limited
validate :validate_post_is_active
before_validation :initialize_creator, :on => :create
validates_uniqueness_of :creator_id, :scope => :post_id
before_save :update_post
def update_post
post.update_attribute(:is_flagged, true)
end
def validate_creator_is_not_limited
if PostAppeal.for_user(creator_id).recent.count >= 10