From 1b36c29a904a300bdc2af1e576f80d84955394da Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 30 Aug 2019 17:59:37 +0800 Subject: [PATCH] 1 --- app/controllers/managements_controller.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 7d30f136..15647eb2 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -3032,17 +3032,10 @@ end # 用户不存在则创建账号 if !user.present? && school.present? department = school.departments.where(:name => list[2]).first - user = User.new - user.admin = false - user.activate - user.login = prefix + list[0].to_s.strip - user.lastname = list[1].to_s.strip - user.nickname = list[1].to_s.strip - user.professional_certification = 1 - user.certification = 1 - user.grade = 0 - user.password = "12345678" - user.phone = list[5].blank? ? nil : list[5] + user_params = {status: 1, login: prefix + list[0].to_s.strip, lastname: list[1].to_s.strip, + nickname: list[1].to_s.strip, professional_certification: 1, certification: 1, grade: 0, + password: "12345678", phone: list[5].blank? ? nil : list[5], mail: nil} + user = User.create(user_params) if user.save(validate: false) ue = UserExtensions.new(:user_id => user.id, :gender => 0, :school_id => school_id, :location => school.province, :location_city => school.city, :identity => list[3].to_i, :student_id => list[0].to_s.strip, :department_id => department.try(:id)) if list[3] && list[3].to_i == 0