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