Fix #3380: Change category on Bulk Update Requests are broken.
This commit is contained in:
@@ -15,6 +15,10 @@ module BulkUpdateRequestsHelper
|
|||||||
when :remove_implication
|
when :remove_implication
|
||||||
TagImplication.where(antecedent_name: antecedent, consequent_name: consequent, status: "deleted").exists? || !TagImplication.where(antecedent_name: antecedent, consequent_name: consequent).exists?
|
TagImplication.where(antecedent_name: antecedent, consequent_name: consequent, status: "deleted").exists? || !TagImplication.where(antecedent_name: antecedent, consequent_name: consequent).exists?
|
||||||
|
|
||||||
|
when :change_category
|
||||||
|
tag, category = antecedent, consequent
|
||||||
|
Tag.where(name: tag, category: Tag.categories.value_for(category)).exists?
|
||||||
|
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
@@ -38,7 +42,7 @@ module BulkUpdateRequestsHelper
|
|||||||
def script_with_line_breaks(script)
|
def script_with_line_breaks(script)
|
||||||
escaped_script = AliasAndImplicationImporter.tokenize(script).map do |cmd, arg1, arg2|
|
escaped_script = AliasAndImplicationImporter.tokenize(script).map do |cmd, arg1, arg2|
|
||||||
case cmd
|
case cmd
|
||||||
when :create_alias, :create_implication, :remove_alias, :remove_implication, :mass_update
|
when :create_alias, :create_implication, :remove_alias, :remove_implication, :mass_update, :change_category
|
||||||
if approved?(cmd, arg1, arg2)
|
if approved?(cmd, arg1, arg2)
|
||||||
btag = '<s class="approved">'
|
btag = '<s class="approved">'
|
||||||
etag = '</s>'
|
etag = '</s>'
|
||||||
@@ -79,6 +83,11 @@ module BulkUpdateRequestsHelper
|
|||||||
when :mass_update
|
when :mass_update
|
||||||
"#{btag}mass update " + link_to(arg1, posts_path(:tags => arg1)) + " -> " + link_to(arg2, posts_path(:tags => arg2)) + "#{etag}"
|
"#{btag}mass update " + link_to(arg1, posts_path(:tags => arg1)) + " -> " + link_to(arg2, posts_path(:tags => arg2)) + "#{etag}"
|
||||||
|
|
||||||
|
when :change_category
|
||||||
|
arg1_count = Tag.find_by_name(arg1).try(:post_count).to_i
|
||||||
|
|
||||||
|
"#{btag}category " + link_to(arg1, posts_path(:tags => arg1)) + " (#{arg1_count}) -> (#{arg2})#{etag}"
|
||||||
|
|
||||||
end
|
end
|
||||||
end.join("\n")
|
end.join("\n")
|
||||||
|
|
||||||
|
|||||||
@@ -178,6 +178,9 @@ class BulkUpdateRequest < ApplicationRecord
|
|||||||
when :mass_update
|
when :mass_update
|
||||||
"mass update {{#{token[1]}}} -> #{token[2]}"
|
"mass update {{#{token[1]}}} -> #{token[2]}"
|
||||||
|
|
||||||
|
when :change_category
|
||||||
|
"category [[#{token[1]}]] -> #{token[2]}"
|
||||||
|
|
||||||
else
|
else
|
||||||
raise "Unknown token: #{token[0]}"
|
raise "Unknown token: #{token[0]}"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user