* Approvers can no longer approve an unapproved post if they previously approved it

This commit is contained in:
albert
2010-11-04 18:31:36 -04:00
parent 551c25909c
commit 6076788d60
3 changed files with 22 additions and 36 deletions

View File

@@ -1,4 +1,6 @@
class Post < ActiveRecord::Base
class ApprovalError < Exception ; end
attr_accessor :old_tag_string, :old_parent_id
after_destroy :delete_files
after_save :update_history
@@ -211,9 +213,11 @@ class Post < ActiveRecord::Base
end
def approve!
raise ApprovalError.new("You have already approved this post previously") if approver_string == "approver:#{CurrentUser.name}"
self.is_flagged = false
self.is_pending = false
self.approver_string = "approver:#{CurrentUser.user.name}"
self.approver_string = "approver:#{CurrentUser.name}"
save!
end
end