update import script to save bio to UserProfile
This commit is contained in:
parent
9ffd173873
commit
e3fcd3fa80
|
@ -140,6 +140,7 @@ class ImportScripts::Base
|
||||||
existing = User.where(email: opts[:email].downcase, username: opts[:username]).first
|
existing = User.where(email: opts[:email].downcase, username: opts[:username]).first
|
||||||
return existing if existing and existing.custom_fields["import_id"].to_i == import_id.to_i
|
return existing if existing and existing.custom_fields["import_id"].to_i == import_id.to_i
|
||||||
|
|
||||||
|
bio_raw = opts.delete(:bio_raw)
|
||||||
opts[:name] = User.suggest_name(opts[:name]) if opts[:name]
|
opts[:name] = User.suggest_name(opts[:name]) if opts[:name]
|
||||||
opts[:username] = UserNameSuggester.suggest((opts[:username].present? ? opts[:username] : nil) || opts[:name] || opts[:email])
|
opts[:username] = UserNameSuggester.suggest((opts[:username].present? ? opts[:username] : nil) || opts[:name] || opts[:email])
|
||||||
opts[:email] = opts[:email].downcase
|
opts[:email] = opts[:email].downcase
|
||||||
|
@ -150,7 +151,13 @@ class ImportScripts::Base
|
||||||
u.custom_fields["import_username"] = opts[:username] if opts[:username].present?
|
u.custom_fields["import_username"] = opts[:username] if opts[:username].present?
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
User.transaction do
|
||||||
u.save!
|
u.save!
|
||||||
|
if bio_raw.present?
|
||||||
|
u.user_profile.bio_raw = bio_raw
|
||||||
|
u.user_profile.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
rescue
|
rescue
|
||||||
# try based on email
|
# try based on email
|
||||||
existing = User.find_by(email: opts[:email].downcase)
|
existing = User.find_by(email: opts[:email].downcase)
|
||||||
|
|
Loading…
Reference in New Issue