From b2598b796636e85a01cf5bbbc8d706a5aae68008 Mon Sep 17 00:00:00 2001 From: BrokenEagle Date: Wed, 20 Dec 2017 08:56:46 -0800 Subject: [PATCH] Add validation warning for non-general/meta tags --- app/models/post.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/post.rb b/app/models/post.rb index 1829bc492..ec0f6c5a4 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1744,6 +1744,7 @@ class Post < ApplicationRecord 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 } + repopulated_tags = new_tags.select { |t| (t.category != Tag.categories.general) && (t.category != Tag.categories.meta) && (t.created_at < 1.hour.ago) } if new_general_tags.present? n = new_general_tags.size @@ -1751,6 +1752,12 @@ class Post < ApplicationRecord self.warnings[:base] << "Created #{n} new #{n == 1 ? "tag" : "tags"}: #{tag_wiki_links.join(", ")}" end + if repopulated_tags.present? + n = repopulated_tags.size + tag_wiki_links = repopulated_tags.map { |tag| "[[#{tag.name}]]" } + self.warnings[:base] << "Repopulated #{n} old #{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)}]"