From 7618576e7b14d02ab92b6863d869803fb5b02e30 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Tue, 7 Jul 2015 14:11:13 -0700 Subject: [PATCH] update forum topic on bulk update request approve failure --- app/models/bulk_update_request.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/models/bulk_update_request.rb b/app/models/bulk_update_request.rb index a4132e48e..192cb3cb2 100644 --- a/app/models/bulk_update_request.rb +++ b/app/models/bulk_update_request.rb @@ -37,6 +37,11 @@ class BulkUpdateRequest < ActiveRecord::Base update_attribute(:status, "approved") rescue Exception => x + message_admin_on_failure(x) + update_topic_on_failure(x) + end + + def message_admin_on_failure(x) admin = User.admins.first msg = <<-EOS Bulk Update Request ##{id} failed\n @@ -60,6 +65,13 @@ class BulkUpdateRequest < ActiveRecord::Base dmail.save 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) user_id == user.id || user.is_builder? end