Allow importers to set empty names

This commit is contained in:
Gerhard Schlager 2016-02-21 21:58:47 +01:00
parent dedbb59321
commit 8a486d8cea
1 changed files with 2 additions and 2 deletions

View File

@ -278,7 +278,6 @@ class ImportScripts::Base
avatar_url = opts.delete(:avatar_url)
# Allow the || operations to work with empty strings ''
opts[:name] = nil if opts[:name].blank?
opts[:username] = nil if opts[:username].blank?
opts[:name] = User.suggest_name(opts[:email]) unless opts[:name]
@ -287,7 +286,8 @@ class ImportScripts::Base
opts[:username].length > User.username_length.end ||
!User.username_available?(opts[:username]) ||
!UsernameValidator.new(opts[:username]).valid_format?
opts[:username] = UserNameSuggester.suggest(opts[:username] || opts[:name] || opts[:email])
opts[:username] = UserNameSuggester.suggest(opts[:username] || opts[:name].presence || opts[:email])
end
opts[:email] = opts[:email].downcase
opts[:trust_level] = TrustLevel[1] unless opts[:trust_level]