Fix #3626: Artist creation page doesn't autocomplete the name anymore.

This commit is contained in:
evazion
2018-04-12 16:23:59 -05:00
parent 5546d9e98b
commit af9a09c2cb
3 changed files with 8 additions and 15 deletions

View File

@@ -125,9 +125,11 @@
if (data.artists.length === 0) {
var new_artist_params = $.param({
name: data.unique_id,
other_names: data.artist_name,
urls: $.unique([data.profile_url, data.normalized_for_artist_finder_url]).join("\n")
artist: {
name: data.unique_id,
other_names: data.artist_name,
url_string: $.unique([data.profile_url, data.normalized_for_artist_finder_url]).join("\n")
}
});
var link = $("<a>").attr("href", "/artists/new?" + new_artist_params).text("Create new artist");

View File

@@ -304,9 +304,8 @@ class Artist < ApplicationRecord
module FactoryMethods
def new_with_defaults(params)
Artist.new.tap do |artist|
if params[:name]
artist.name = params[:name]
Artist.new(params).tap do |artist|
if artist.name.present?
post = CurrentUser.without_safe_mode do
Post.tag_match("source:http #{artist.name}").where("true /* Artist.new_with_defaults */").first
end
@@ -314,14 +313,6 @@ class Artist < ApplicationRecord
artist.url_string = post.source
end
end
if params[:other_names]
artist.other_names = params[:other_names]
end
if params[:urls]
artist.url_string = params[:urls]
end
end
end
end

View File

@@ -1711,7 +1711,7 @@ class Post < ApplicationRecord
new_artist_tags.each do |tag|
if tag.artist.blank?
self.warnings[:base] << "Artist [[#{tag.name}]] requires an artist entry. \"Create new artist entry\":[/artists/new?name=#{CGI::escape(tag.name)}]"
self.warnings[:base] << "Artist [[#{tag.name}]] requires an artist entry. \"Create new artist entry\":[/artists/new?artist%5Bname%5D=#{CGI::escape(tag.name)}]"
end
end
end