Fix team import for user with avatars

This commit is contained in:
aignatov-bio 2019-11-04 14:53:59 +01:00
parent ec66ab8654
commit b56a997aef

View file

@ -373,12 +373,13 @@ 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)
avatar = File.open(avatar_path)
user.avatar.attach(io: avatar, filename: avatar_filename)
end
@user_counter += 1
user.update_attribute('encrypted_password',
user_json['user']['encrypted_password'])