Fix #4470: Check URLs for duplicates when creating artists
Show a warning when creating a duplicate artist; that is, when adding a URL that already belongs to another artist. This is a soft warning rather than a hard error because there are some cases where multiple artists legitimately share the same site or account.
This commit is contained in:
@@ -15,6 +15,7 @@ class Artist < ApplicationRecord
|
||||
|
||||
validate :validate_artist_name
|
||||
validates :name, tag_name: true, uniqueness: true
|
||||
after_validation :add_url_warnings
|
||||
|
||||
before_save :update_tag_category
|
||||
after_save :create_version
|
||||
@@ -302,6 +303,12 @@ class Artist < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def add_url_warnings
|
||||
urls.each do |url|
|
||||
warnings.add(:base, url.warnings.full_messages.join("; ")) if url.warnings.any?
|
||||
end
|
||||
end
|
||||
|
||||
include UrlMethods
|
||||
include VersionMethods
|
||||
extend FactoryMethods
|
||||
|
||||
Reference in New Issue
Block a user