Fix #3374: List approver in BUR approval messages.
This commit is contained in:
@@ -38,7 +38,7 @@ class BulkUpdateRequestsController < ApplicationController
|
||||
|
||||
def destroy
|
||||
if @bulk_update_request.editable?(CurrentUser.user)
|
||||
@bulk_update_request.reject!
|
||||
@bulk_update_request.reject!(CurrentUser.user)
|
||||
flash[:notice] = "Bulk update request rejected"
|
||||
respond_with(@bulk_update_request, :location => bulk_update_requests_path)
|
||||
else
|
||||
|
||||
@@ -33,6 +33,6 @@ class ForumUpdater
|
||||
end
|
||||
|
||||
def update_post(body)
|
||||
forum_post.update(:body => "#{forum_post.body}\n\n#{body}")
|
||||
forum_post.update(:body => "#{forum_post.body}\n\nEDIT: #{body}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -95,13 +95,13 @@ class BulkUpdateRequest < ApplicationRecord
|
||||
CurrentUser.scoped(approver) do
|
||||
AliasAndImplicationImporter.new(script, forum_topic_id, "1", true).process!
|
||||
update({ :status => "approved", :approver_id => CurrentUser.id, :skip_secondary_validations => true }, :as => CurrentUser.role)
|
||||
forum_updater.update("The \"bulk update request ##{id}\":/bulk_update_requests?search%5Bid%5D=#{id} has been approved.", "APPROVED")
|
||||
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been approved by @#{approver.name}.", "APPROVED")
|
||||
end
|
||||
|
||||
rescue Exception => x
|
||||
self.approver = approver
|
||||
CurrentUser.scoped(approver) do
|
||||
forum_updater.update("The \"Bulk update request ##{id}\":/bulk_update_requests?search%5Bid%5D=#{id} has failed: #{x.to_s}", "FAILED")
|
||||
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has failed: #{x.to_s}", "FAILED")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -119,10 +119,14 @@ class BulkUpdateRequest < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def reject!
|
||||
forum_updater.update("The \"bulk update request ##{id}\":/bulk_update_requests?search%5Bid%5D=#{id} has been rejected.", "REJECTED")
|
||||
def reject!(rejector)
|
||||
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been rejected by @#{rejector.name}.", "REJECTED")
|
||||
update_attribute(:status, "rejected")
|
||||
end
|
||||
|
||||
def bulk_update_request_link
|
||||
%{"bulk update request ##{id}":/bulk_update_requests?search%5Bid%5D=#{id}}
|
||||
end
|
||||
end
|
||||
|
||||
module ValidationMethods
|
||||
|
||||
@@ -42,10 +42,6 @@ class TagAlias < TagRelationship
|
||||
delay(:queue => "default").process!(update_topic: update_topic)
|
||||
end
|
||||
end
|
||||
|
||||
def conflict_message
|
||||
"The tag alias [[#{antecedent_name}]] -> [[#{consequent_name}]] (alias ##{id}) has conflicting wiki pages. [[#{consequent_name}]] should be updated to include information from [[#{antecedent_name}]] if necessary."
|
||||
end
|
||||
end
|
||||
|
||||
module ForumMethods
|
||||
@@ -90,7 +86,7 @@ class TagAlias < TagRelationship
|
||||
clear_all_cache
|
||||
ensure_category_consistency
|
||||
update_posts
|
||||
forum_updater.update(approval_message, "APPROVED") if update_topic
|
||||
forum_updater.update(approval_message(approver), "APPROVED") if update_topic
|
||||
rename_wiki_and_artist
|
||||
update({ :status => "active", :post_count => consequent_tag.post_count }, :as => CurrentUser.role)
|
||||
end
|
||||
@@ -227,7 +223,7 @@ class TagAlias < TagRelationship
|
||||
def reject!
|
||||
update({ :status => "deleted" }, :as => CurrentUser.role)
|
||||
clear_all_cache
|
||||
forum_updater.update(reject_message, "REJECTED")
|
||||
forum_updater.update(reject_message(CurrentUser.user), "REJECTED")
|
||||
destroy
|
||||
end
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ class TagImplication < TagRelationship
|
||||
update_posts
|
||||
update({ :status => "active" }, :as => CurrentUser.role)
|
||||
update_descendant_names_for_parents
|
||||
forum_updater.update(approval_message, "APPROVED") if update_topic
|
||||
forum_updater.update(approval_message(approver), "APPROVED") if update_topic
|
||||
end
|
||||
rescue Exception => e
|
||||
if tries < 5
|
||||
@@ -186,7 +186,7 @@ class TagImplication < TagRelationship
|
||||
|
||||
def reject!
|
||||
update({ :status => "deleted", }, :as => CurrentUser.role)
|
||||
forum_updater.update(reject_message, "REJECTED")
|
||||
forum_updater.update(reject_message(CurrentUser.user), "REJECTED")
|
||||
destroy
|
||||
end
|
||||
|
||||
|
||||
@@ -123,21 +123,29 @@ class TagRelationship < ApplicationRecord
|
||||
self.class.name.underscore.tr("_", " ")
|
||||
end
|
||||
|
||||
def approval_message
|
||||
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] has been approved."
|
||||
def approval_message(approver)
|
||||
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] #{forum_link} has been approved by @#{approver.name}."
|
||||
end
|
||||
|
||||
def failure_message(e = nil)
|
||||
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] failed during processing. Reason: #{e}"
|
||||
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] #{forum_link} failed during processing. Reason: #{e}"
|
||||
end
|
||||
|
||||
def reject_message
|
||||
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] has been rejected."
|
||||
def reject_message(rejector)
|
||||
"The #{relationship} [[#{antecedent_name}]] -> [[#{consequent_name}]] #{forum_link} has been rejected by @#{rejector.name}."
|
||||
end
|
||||
|
||||
def conflict_message
|
||||
"The tag alias [[#{antecedent_name}]] -> [[#{consequent_name}]] #{forum_link} has conflicting wiki pages. [[#{consequent_name}]] should be updated to include information from [[#{antecedent_name}]] if necessary."
|
||||
end
|
||||
|
||||
def date_timestamp
|
||||
Time.now.strftime("%Y-%m-%d")
|
||||
end
|
||||
|
||||
def forum_link
|
||||
"(forum ##{forum_post.id})" if forum_post.present?
|
||||
end
|
||||
end
|
||||
|
||||
extend SearchMethods
|
||||
|
||||
@@ -127,7 +127,7 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
@req.approver_id = @admin.id
|
||||
|
||||
assert_difference("ForumPost.count") do
|
||||
@req.reject!
|
||||
@req.reject!(@admin)
|
||||
end
|
||||
|
||||
@topic.reload
|
||||
|
||||
Reference in New Issue
Block a user