Fix #1563: Warn users attempting to upload with very few tags.
This commit is contained in:
@@ -22,6 +22,7 @@ class Post < ApplicationRecord
|
|||||||
validate :removed_tags_are_valid
|
validate :removed_tags_are_valid
|
||||||
validate :has_artist_tag
|
validate :has_artist_tag
|
||||||
validate :has_copyright_tag
|
validate :has_copyright_tag
|
||||||
|
validate :has_enough_tags
|
||||||
validate :post_is_not_its_own_parent
|
validate :post_is_not_its_own_parent
|
||||||
validate :updater_can_change_rating
|
validate :updater_can_change_rating
|
||||||
before_save :update_tag_post_counts
|
before_save :update_tag_post_counts
|
||||||
@@ -1793,6 +1794,14 @@ class Post < ApplicationRecord
|
|||||||
|
|
||||||
self.warnings[:base] << "Copyright tag is required. Consider adding [[copyright request]] or [[original]]"
|
self.warnings[:base] << "Copyright tag is required. Consider adding [[copyright request]] or [[original]]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_enough_tags
|
||||||
|
return if !new_record?
|
||||||
|
|
||||||
|
if tags.count { |t| t.category == Tag.categories.general } < 10
|
||||||
|
self.warnings[:base] << "Uploads must have at least 10 general tags. Read [[howto:tag]] for guidelines on tagging your uploads"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
include FileMethods
|
include FileMethods
|
||||||
|
|||||||
@@ -1636,6 +1636,11 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
should "warn when missing a copyright tag" do
|
should "warn when missing a copyright tag" do
|
||||||
assert_match(/Copyright tag is required/, @post.warnings.full_messages.join)
|
assert_match(/Copyright tag is required/, @post.warnings.full_messages.join)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "warn when an upload doesn't have enough tags" do
|
||||||
|
post = FactoryGirl.create(:post, tag_string: "tagme")
|
||||||
|
assert_match(/Uploads must have at least \d+ general tags/, post.warnings.full_messages.join)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user