posts: warn when adding artist tag with no artist entry.

This commit is contained in:
evazion
2017-11-08 19:37:09 -06:00
parent 963eacd849
commit d571efd703
2 changed files with 8 additions and 0 deletions

View File

@@ -1724,12 +1724,19 @@ class Post < ApplicationRecord
def added_tags_are_valid
new_tags = added_tags.select { |t| t.post_count <= 1 }
new_general_tags = new_tags.select { |t| t.category == Tag.categories.general }
new_artist_tags = new_tags.select { |t| t.category == Tag.categories.artist }
if new_general_tags.present?
n = new_general_tags.size
tag_wiki_links = new_general_tags.map { |tag| "[[#{tag.name}]]" }
self.warnings[:base] << "Created #{n} new #{n == 1 ? "tag" : "tags"}: #{tag_wiki_links.join(", ")}"
end
new_artist_tags.each do |tag|
if tag.artist.blank?
self.warnings[:base] << "Artist [[#{tag.name}]] requires an artist entry. \"Create new artist entry\":[/artists/new?name=#{CGI::escape(tag.name)}]"
end
end
end
end