Merge pull request #3504 from BrokenEagle/fix-3494
Fix how cosplay tags are handled
This commit is contained in:
@@ -705,6 +705,8 @@ class Post < ApplicationRecord
|
||||
normalized_tags = TagAlias.to_aliased(normalized_tags)
|
||||
normalized_tags = %w(tagme) if normalized_tags.empty?
|
||||
normalized_tags = add_automatic_tags(normalized_tags)
|
||||
normalized_tags = remove_invalid_tags(normalized_tags)
|
||||
normalized_tags = Tag.convert_cosplay_tags(normalized_tags)
|
||||
normalized_tags = normalized_tags + Tag.create_for_list(TagImplication.automatic_tags_for(normalized_tags))
|
||||
normalized_tags = TagImplication.with_descendants(normalized_tags)
|
||||
normalized_tags = normalized_tags.compact.uniq.sort
|
||||
@@ -712,6 +714,14 @@ class Post < ApplicationRecord
|
||||
set_tag_string(normalized_tags.join(" "))
|
||||
end
|
||||
|
||||
def remove_invalid_tags(tags)
|
||||
invalid_tags = Tag.invalid_cosplay_tags(tags)
|
||||
if invalid_tags.present?
|
||||
self.warnings[:base] << "The root tag must be a character tag: #{invalid_tags.map {|tag| "[b]#{tag}[/b]" }.join(", ")}"
|
||||
end
|
||||
tags - invalid_tags
|
||||
end
|
||||
|
||||
def remove_negated_tags(tags)
|
||||
@negated_tags, tags = tags.partition {|x| x =~ /\A-/i}
|
||||
@negated_tags = @negated_tags.map {|x| x[1..-1]}
|
||||
|
||||
Reference in New Issue
Block a user