wikis: don't allow adding other names to artist wikis.
Prevent users from adding other names to artist wikis. These should be added to the artist entry instead.
This commit is contained in:
@@ -7,10 +7,12 @@ class WikiPage < ApplicationRecord
|
||||
before_save :normalize_other_names
|
||||
before_save :update_dtext_links, if: :dtext_links_changed?
|
||||
after_save :create_version
|
||||
|
||||
validates_uniqueness_of :title, :case_sensitive => false
|
||||
validates_presence_of :title
|
||||
validates_presence_of :body, :unless => -> { is_deleted? || other_names.present? }
|
||||
validate :validate_rename
|
||||
validate :validate_other_names
|
||||
|
||||
array_attribute :other_names
|
||||
has_one :tag, :foreign_key => "name", :primary_key => "title"
|
||||
@@ -124,6 +126,12 @@ class WikiPage < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def validate_other_names
|
||||
if other_names.present? && tag&.artist?
|
||||
errors.add(:base, "An artist wiki can't have other names")
|
||||
end
|
||||
end
|
||||
|
||||
def revert_to(version)
|
||||
if id != version.wiki_page_id
|
||||
raise RevertError.new("You cannot revert to a previous version of another wiki page.")
|
||||
|
||||
Reference in New Issue
Block a user