forked from e621ng/e621ng
[BUR] Correctly set the creator of new aliases/implications
The approver was getting put as the creator.
This commit is contained in:
parent
0e6640871f
commit
80d5d8f2ee
@ -196,17 +196,17 @@ private
|
||||
# a BUR, and makes it much easier to work with.
|
||||
def find_create_alias(token, approver)
|
||||
tag_alias = TagAlias.duplicate_relevant.find_by(antecedent_name: token[1], consequent_name: token[2])
|
||||
alias_values = { creator_id: creator_id, creator_ip_addr: creator_ip_addr, forum_topic_id: forum_id }
|
||||
if tag_alias.present?
|
||||
return unless tag_alias.status == 'pending'
|
||||
tag_alias.update_columns(creator_id: creator_id, creator_ip_addr: creator_ip_addr, forum_topic_id: forum_id)
|
||||
tag_alias.update_columns(**alias_values)
|
||||
else
|
||||
tag_alias = TagAlias.create(:forum_topic_id => forum_id, :status => "pending", :antecedent_name => token[1], :consequent_name => token[2])
|
||||
tag_alias = TagAlias.create(status: "pending", antecedent_name: token[1], consequent_name: token[2], **alias_values)
|
||||
unless tag_alias.valid?
|
||||
raise Error, "Error: #{tag_alias.errors.full_messages.join("; ")} (create alias #{tag_alias.antecedent_name} -> #{tag_alias.consequent_name})"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tag_alias.rename_artist if rename_aliased_pages?
|
||||
raise Error, "Error: Alias would modify other aliases or implications through transitive relationships. (create alias #{tag_alias.antecedent_name} -> #{tag_alias.consequent_name})" if tag_alias.has_transitives
|
||||
tag_alias.approve!(approver: approver, update_topic: false, deny_transitives: true)
|
||||
@ -214,11 +214,12 @@ private
|
||||
|
||||
def find_create_implication(token, approver)
|
||||
tag_implication = TagImplication.duplicate_relevant.find_by(antecedent_name: token[1], consequent_name: token[2])
|
||||
implication_values = { creator_id: creator_id, creator_ip_addr: creator_ip_addr, forum_topic_id: forum_id }
|
||||
if tag_implication.present?
|
||||
return unless tag_implication.status == 'pending'
|
||||
tag_implication.update_columns(creator_id: creator_id, creator_ip_addr: creator_ip_addr, forum_topic_id: forum_id)
|
||||
tag_implication.update_columns(**implication_values)
|
||||
else
|
||||
tag_implication = TagImplication.create(:forum_topic_id => forum_id, :status => "pending", :antecedent_name => token[1], :consequent_name => token[2])
|
||||
tag_implication = TagImplication.create(status: "pending", antecedent_name: token[1], consequent_name: token[2], **implication_values)
|
||||
unless tag_implication.valid?
|
||||
raise Error, "Error: #{tag_implication.errors.full_messages.join("; ")} (create implication #{tag_implication.antecedent_name} -> #{tag_implication.consequent_name})"
|
||||
end
|
||||
|
@ -37,8 +37,8 @@ class TagRelationship < ApplicationRecord
|
||||
after_save :update_notice
|
||||
|
||||
def initialize_creator
|
||||
self.creator_id = CurrentUser.user.id
|
||||
self.creator_ip_addr = CurrentUser.ip_addr
|
||||
self.creator_id ||= CurrentUser.user.id
|
||||
self.creator_ip_addr ||= CurrentUser.ip_addr
|
||||
end
|
||||
|
||||
def normalize_names
|
||||
|
Loading…
Reference in New Issue
Block a user