BURs: make rename command move aliases/implications.
Make the tag rename command also move any aliases or implications from the old tag to the new tag. Previously only the create alias command moved aliases and implications.
This commit is contained in:
@@ -16,7 +16,6 @@ class TagAlias < TagRelationship
|
||||
|
||||
def process!(approver)
|
||||
update!(approver: approver, status: "processing")
|
||||
move_aliases_and_implications
|
||||
TagMover.new(antecedent_name, consequent_name, user: User.system).move!
|
||||
update!(status: "active")
|
||||
rescue Exception => e
|
||||
@@ -34,35 +33,6 @@ class TagAlias < TagRelationship
|
||||
end
|
||||
end
|
||||
|
||||
def move_aliases_and_implications
|
||||
aliases = TagAlias.where(["consequent_name = ?", antecedent_name])
|
||||
aliases.each do |ta|
|
||||
ta.consequent_name = self.consequent_name
|
||||
success = ta.save
|
||||
if !success && ta.errors.full_messages.join("; ") =~ /Cannot alias a tag to itself/
|
||||
ta.destroy
|
||||
end
|
||||
end
|
||||
|
||||
implications = TagImplication.where(["antecedent_name = ?", antecedent_name])
|
||||
implications.each do |ti|
|
||||
ti.antecedent_name = self.consequent_name
|
||||
success = ti.save
|
||||
if !success && ti.errors.full_messages.join("; ") =~ /Cannot implicate a tag to itself/
|
||||
ti.destroy
|
||||
end
|
||||
end
|
||||
|
||||
implications = TagImplication.where(["consequent_name = ?", antecedent_name])
|
||||
implications.each do |ti|
|
||||
ti.consequent_name = self.consequent_name
|
||||
success = ti.save
|
||||
if !success && ti.errors.full_messages.join("; ") =~ /Cannot implicate a tag to itself/
|
||||
ti.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create_mod_action
|
||||
alias_desc = %("tag alias ##{id}":[#{Rails.application.routes.url_helpers.tag_alias_path(self)}]: [[#{antecedent_name}]] -> [[#{consequent_name}]])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user