update forum topic on bulk update request approve failure
This commit is contained in:
@@ -37,6 +37,11 @@ class BulkUpdateRequest < ActiveRecord::Base
|
|||||||
update_attribute(:status, "approved")
|
update_attribute(:status, "approved")
|
||||||
|
|
||||||
rescue Exception => x
|
rescue Exception => x
|
||||||
|
message_admin_on_failure(x)
|
||||||
|
update_topic_on_failure(x)
|
||||||
|
end
|
||||||
|
|
||||||
|
def message_admin_on_failure(x)
|
||||||
admin = User.admins.first
|
admin = User.admins.first
|
||||||
msg = <<-EOS
|
msg = <<-EOS
|
||||||
Bulk Update Request ##{id} failed\n
|
Bulk Update Request ##{id} failed\n
|
||||||
@@ -60,6 +65,13 @@ class BulkUpdateRequest < ActiveRecord::Base
|
|||||||
dmail.save
|
dmail.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_topic_on_failure(x)
|
||||||
|
if forum_topic_id
|
||||||
|
body = "Bulk update request ##{id} failed: #{x.to_s}"
|
||||||
|
ForumPost.create(:body => body, :topic_id => forum_topic_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def editable?(user)
|
def editable?(user)
|
||||||
user_id == user.id || user.is_builder?
|
user_id == user.id || user.is_builder?
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user