From 4cd372296d7bc713f24dda867dda85f5af731c3a Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 25 Nov 2017 13:45:17 -0600 Subject: [PATCH] posts: warn when post is missing copyright tags. --- app/models/post.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/post.rb b/app/models/post.rb index 8795beed2..ec929b874 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -19,6 +19,7 @@ class Post < ApplicationRecord validates_inclusion_of :rating, in: %w(s q e), message: "rating must be s, q, or e" validate :tag_names_are_valid validate :added_tags_are_valid + validate :has_copyright_tag validate :post_is_not_its_own_parent validate :updater_can_change_rating before_save :update_tag_post_counts @@ -1738,6 +1739,13 @@ class Post < ApplicationRecord end end end + + def has_copyright_tag + return if !new_record? + return if has_tag?("copyright_request") || tags.any? { |t| t.category == Tag.categories.copyright } + + self.warnings[:base] << "Copyright tag is required. Consider adding [[copyright request]] or [[original]]" + end end include FileMethods