BURs: don't allow implying tags from different categories.
Don't allow requests for implications between tags of different categories. For example, don't allow character tags to imply copyright tags.
This commit is contained in:
@@ -192,6 +192,7 @@ class Artist < ApplicationRecord
|
||||
|
||||
# potential race condition but unlikely
|
||||
unless TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").exists?
|
||||
Tag.find_or_create_by_name("artist:banned_artist") # ensure the banned_artist exists and is an artist tag.
|
||||
TagImplication.approve!(antecedent_name: name, consequent_name: "banned_artist", approver: banner)
|
||||
end
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ class TagImplication < TagRelationship
|
||||
validate :absence_of_transitive_relation
|
||||
validate :antecedent_is_not_aliased
|
||||
validate :consequent_is_not_aliased
|
||||
validate :tag_categories_are_compatible
|
||||
validate :has_wiki_page, on: :request
|
||||
|
||||
concerning :HierarchyMethods do
|
||||
@@ -93,6 +94,12 @@ class TagImplication < TagRelationship
|
||||
end
|
||||
end
|
||||
|
||||
def tag_categories_are_compatible
|
||||
if antecedent_tag.category != consequent_tag.category
|
||||
errors[:base] << "Can't imply a #{antecedent_tag.category_name.downcase} tag to a #{consequent_tag.category_name.downcase} tag"
|
||||
end
|
||||
end
|
||||
|
||||
def has_wiki_page
|
||||
if !antecedent_tag.empty? && antecedent_wiki.blank?
|
||||
errors[:base] << "'#{antecedent_name}' must have a wiki page"
|
||||
|
||||
Reference in New Issue
Block a user