This commit is contained in:
r888888888
2013-07-25 14:32:15 -07:00
parent 303d6ce821
commit c4bf6a9192
6 changed files with 52 additions and 37 deletions

View File

@@ -182,26 +182,28 @@ class Artist < ActiveRecord::Base
module BanMethods
def ban!
Post.transaction do
begin
Post.tag_match(name).each do |post|
begin
post.flag!("Artist requested removal")
rescue PostFlag::Error
# swallow
CurrentUser.without_safe_mode do
begin
Post.tag_match(name).each do |post|
begin
post.flag!("Artist requested removal")
rescue PostFlag::Error
# swallow
end
post.delete!(:ban => true)
end
post.delete!(:ban => true)
rescue Post::SearchError
# swallow
end
rescue Post::SearchError
# swallow
end
# potential race condition but unlikely
unless TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").exists?
tag_implication = TagImplication.create(:antecedent_name => name, :consequent_name => "banned_artist")
tag_implication.delay(:queue => "default").process!
end
# potential race condition but unlikely
unless TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").exists?
tag_implication = TagImplication.create(:antecedent_name => name, :consequent_name => "banned_artist")
tag_implication.delay(:queue => "default").process!
end
update_column(:is_banned, true)
update_column(:is_banned, true)
end
end
end
end

View File

@@ -126,18 +126,20 @@ class TagAlias < ActiveRecord::Base
end
def update_posts
Post.raw_tag_match(antecedent_name).find_each do |post|
escaped_antecedent_name = Regexp.escape(antecedent_name)
fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip
CurrentUser.scoped(creator, creator_ip_addr) do
post.update_attributes(
:tag_string => fixed_tags
)
CurrentUser.without_safe_mode do
Post.raw_tag_match(antecedent_name).find_each do |post|
escaped_antecedent_name = Regexp.escape(antecedent_name)
fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip
CurrentUser.scoped(creator, creator_ip_addr) do
post.update_attributes(
:tag_string => fixed_tags
)
end
end
end
antecedent_tag.fix_post_count if antecedent_tag
consequent_tag.fix_post_count if consequent_tag
antecedent_tag.fix_post_count if antecedent_tag
consequent_tag.fix_post_count if consequent_tag
end
end
def rename_wiki_and_artist

View File

@@ -126,12 +126,14 @@ class TagImplication < ActiveRecord::Base
end
def update_posts
Post.raw_tag_match(antecedent_name).find_each do |post|
fixed_tags = "#{post.tag_string} #{descendant_names}".strip
CurrentUser.scoped(creator, creator_ip_addr) do
post.update_attributes(
:tag_string => fixed_tags
)
CurrentUser.without_safe_mode do
Post.raw_tag_match(antecedent_name).find_each do |post|
fixed_tags = "#{post.tag_string} #{descendant_names}".strip
CurrentUser.scoped(creator, creator_ip_addr) do
post.update_attributes(
:tag_string => fixed_tags
)
end
end
end
end