implemented javascripts for approval/disapproval/unapproval from post/show page

This commit is contained in:
albert
2011-02-10 19:08:23 -05:00
parent 00ea319743
commit 33f5350677
19 changed files with 234 additions and 17 deletions

View File

@@ -4,7 +4,22 @@ class Unapproval < ActiveRecord::Base
belongs_to :unapprover, :class_name => "User"
belongs_to :post
validates_presence_of :reason, :unapprover_id, :unapprover_ip_addr
validate :validate_post_is_active
before_validation :initialize_unapprover, :on => :create
before_save :flag_post
def validate_post_is_active
if post.is_pending? || post.is_flagged? || post.is_removed?
errors[:post] << "is inactive"
false
else
true
end
end
def flag_post
post.update_attribute(:is_flagged, true)
end
def initialize_unapprover
self.unapprover_id = CurrentUser.id