artists: improve prefilling of new artist form (#4028)

* When creating an artist by clicking the '?' next to the artist tag in
  the tag list, prefill the new artist form by finding the artist's last
  upload and fetching its source data.

  Previously we filled the urls with the source of the artist's last
  upload, which was wrong because it was usually a direct image URL (#3078).

* Fix the other names field not escaping spaces within names to underscores.

* Fix the other names field being potentially prefilled with duplicate names.
This commit is contained in:
evazion
2018-12-27 15:03:11 -06:00
parent 286bf2f285
commit 2170961f47
5 changed files with 52 additions and 11 deletions

View File

@@ -6,7 +6,7 @@ class ArtistsController < ApplicationController
before_action :load_artist, :only => [:ban, :unban, :show, :edit, :update, :destroy, :undelete]
def new
@artist = Artist.new_with_defaults(artist_params)
@artist = Artist.new_with_defaults(artist_params(:new))
respond_with(@artist)
end
@@ -104,9 +104,10 @@ private
sp.permit!
end
def artist_params
def artist_params(context = nil)
permitted_params = %i[name other_names other_names_string group_name url_string notes]
permitted_params << :is_active if CurrentUser.is_builder?
permitted_params << :source if context == :new
params.fetch(:artist, {}).permit(permitted_params)
end