BURs: don't allow renames for tags with more than 200 posts.

Don't allow tags with more than 200 posts to be renamed. An alias must
be used instead.
This commit is contained in:
evazion
2020-12-03 14:24:16 -06:00
parent 1c9a926eac
commit 8a959b44df
2 changed files with 12 additions and 0 deletions

View File

@@ -1,4 +1,6 @@
class BulkUpdateRequestProcessor
MAXIMUM_RENAME_COUNT = 200
include ActiveModel::Validations
class Error < StandardError; end
@@ -87,6 +89,8 @@ class BulkUpdateRequestProcessor
tag = Tag.find_by_name(args[0])
if tag.nil?
errors[:base] << "Can't rename #{args[0]} -> #{args[1]} (the '#{args[0]}' tag doesn't exist)"
elsif tag.post_count > MAXIMUM_RENAME_COUNT
errors[:base] << "Can't rename #{args[0]} -> #{args[1]} ('#{args[0]}' has more than #{MAXIMUM_RENAME_COUNT} posts, use an alias instead)"
end
when :mass_update, :nuke