Tags: don't allow deprecation of tags without wiki

This commit is contained in:
nonamethanks
2022-04-09 16:26:13 +02:00
parent a4659b4d09
commit 11281d6f58
4 changed files with 68 additions and 40 deletions

View File

@@ -131,13 +131,19 @@ class BulkUpdateRequestProcessor
when :deprecate
tag = Tag.find_by_name(args[0])
if tag.is_deprecated?
if tag.nil?
errors.add(:base, "Can't deprecate #{args[0]} (tag doesn't exist)")
elsif tag.is_deprecated?
errors.add(:base, "Can't deprecate #{args[0]} (tag is already deprecated)")
elsif tag.wiki_page.blank?
errors.add(:base, "Can't deprecate #{args[0]} (tag must have a wiki page)")
end
when :undeprecate
tag = Tag.find_by_name(args[0])
if !tag.is_deprecated?
if tag.nil?
errors.add(:base, "Can't undeprecate #{args[0]} (tag doesn't exist)")
elsif !tag.is_deprecated?
errors.add(:base, "Can't undeprecate #{args[0]} (tag is not deprecated)")
end