stuff
This commit is contained in:
@@ -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])}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user