update forum topic when alias/implication/update request is updated

This commit is contained in:
r888888888
2015-02-15 12:51:02 -08:00
parent b524c2dfba
commit 387dece55a
8 changed files with 142 additions and 4 deletions

View File

@@ -31,6 +31,7 @@ class BulkUpdateRequest < ActiveRecord::Base
extend SearchMethods
def approve!
update_forum_topic_for_approve
AliasAndImplicationImporter.new(script, forum_topic_id, "1").process!
update_attribute(:status, "approved")
end
@@ -70,6 +71,7 @@ class BulkUpdateRequest < ActiveRecord::Base
end
def reject!
update_forum_topic_for_reject
update_attribute(:status, "rejected")
end
@@ -91,4 +93,25 @@ class BulkUpdateRequest < ActiveRecord::Base
errors.add(:base, "Forum topic ID is invalid")
end
end
def update_forum_topic_for_approve
if forum_topic
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
forum_topic.posts.create(
:body => "The bulk update request ##{id} has been approved."
)
end
end
end
def update_forum_topic_for_reject
if forum_topic
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
forum_topic.posts.create(
:body => "The bulk update request ##{id} has been rejected."
)
end
end
end
end