added post pruner, added mod action notifications when approving/deleting posts
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
class ModAction < ActiveRecord::Base
|
||||
belongs_to :creator, :class_name => "User"
|
||||
before_validation :initialize_creator, :on => :create
|
||||
|
||||
def initialize_creator
|
||||
self.creator_id = CurrentUser.id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -299,6 +299,7 @@ class Post < ActiveRecord::Base
|
||||
self.is_deleted = false
|
||||
self.approver_id = CurrentUser.id
|
||||
save!
|
||||
ModAction.create(:description => "approved post ##{id}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -900,6 +901,7 @@ class Post < ActiveRecord::Base
|
||||
update_column(:is_deleted, true)
|
||||
update_parent_on_destroy
|
||||
tag_array.each {|x| expire_cache(x)}
|
||||
ModAction.create(:description => "deleted post ##{id}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -907,6 +909,7 @@ class Post < ActiveRecord::Base
|
||||
update_column(:is_deleted, false)
|
||||
tag_array.each {|x| expire_cache(x)}
|
||||
update_parent_on_save
|
||||
ModAction.create(:description => "undeleted post ##{id}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@ class PostFlag < ActiveRecord::Base
|
||||
before_validation :initialize_creator, :on => :create
|
||||
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "has already flagged this post"
|
||||
before_save :update_post
|
||||
scope :resolved, where(["is_resolved = ?", true])
|
||||
scope :unresolved, where(["is_resolved = ?", false])
|
||||
scope :resolved, where("is_resolved = ?", true)
|
||||
scope :unresolved, where("is_resolved = ?", false)
|
||||
scope :old, lambda {where("created_at <= ?", 3.days.ago)}
|
||||
|
||||
def update_post
|
||||
post.update_column(:is_flagged, true)
|
||||
|
||||
Reference in New Issue
Block a user