mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 21:21:50 +08:00
Merge pull request #2195 from aignatov-bio/ai-sci-4051-fix-team-import-for-avatars
Fix team import for user with avatars [SCI-4051]
This commit is contained in:
commit
938ea259cc
1 changed files with 8 additions and 5 deletions
|
@ -373,12 +373,15 @@ class TeamImporter
|
|||
user.password = user_json['user']['encrypted_password']
|
||||
user.current_team_id = team.id
|
||||
user.invited_by_id = @user_mappings[user.invited_by_id]
|
||||
if user_json['user']['avatar']
|
||||
avatar_path = File.join(@import_dir, 'avatars', orig_user_id.to_s,
|
||||
user_json['user']['avatar']['filename'])
|
||||
File.open(avatar_path) { |f| user.avatar = f } if File.exist?(avatar_path)
|
||||
end
|
||||
user.save!
|
||||
if user_json['user']['avatar']
|
||||
avatar_filename = user_json['user']['avatar']['filename']
|
||||
avatar_path = File.join(@import_dir, 'avatars', orig_user_id.to_s, avatar_filename)
|
||||
if File.exist?(avatar_path)
|
||||
avatar = File.open(avatar_path)
|
||||
user.avatar.attach(io: avatar, filename: avatar_filename)
|
||||
end
|
||||
end
|
||||
@user_counter += 1
|
||||
user.update_attribute('encrypted_password',
|
||||
user_json['user']['encrypted_password'])
|
||||
|
|
Loading…
Reference in a new issue