Merge branch 'dev_aliyun' into educoder

dev_aliyun
cxt 5 years ago
commit 9ca92d5ad3

@ -2967,7 +2967,7 @@ end
member = course.course_members.where(:user_id => user.id, :role => member_role).first member = course.course_members.where(:user_id => user.id, :role => member_role).first
# 如果已是课堂成员且是学生身份and不在指定的分班则移动到该分班 # 如果已是课堂成员且是学生身份and不在指定的分班则移动到该分班
if member.present? && member.role == 4 && member.course_group_id != course_group.try(:id).to_i if member.present? && member.role == 4 && member.course_group_id != course_group.try(:id).to_i
member.update_column("course_group_id", course_group.try(:id).to_i) member.update_attributes(course_group_id: course_group.try(:id).to_i)
member_count += 1 member_count += 1
elsif !member.present? elsif !member.present?
member = CourseMember.new(:role => member_role, :user_id => user.id) member = CourseMember.new(:role => member_role, :user_id => user.id)
@ -2988,9 +2988,9 @@ end
@status = 1 @status = 1
@message = "已导入/更新#{member_count}个成员" @message = "已导入/更新#{member_count}个成员"
end end
rescue rescue Exception => e
@status = 0 @status = 0
@message = "文件内容无法读取" @message = e.message
end end
else else
@status = 0 @status = 0
@ -3032,18 +3032,12 @@ end
# 用户不存在则创建账号 # 用户不存在则创建账号
if !user.present? && school.present? if !user.present? && school.present?
department = school.departments.where(:name => list[2]).first department = school.departments.where(:name => list[2]).first
user = User.new user_params = {status: 1, login: prefix + list[0].to_s.strip, lastname: list[1].to_s.strip,
user.admin = false nickname: list[1].to_s.strip, professional_certification: 1, certification: 1, grade: 0,
user.activate password: "12345678", phone: list[5].blank? ? nil : list[5], mail: "#{prefix+list[0].to_s.strip}@qq.com", profile_completed: 1}
user.login = prefix + list[0].to_s.strip user = User.create(user_params)
user.lastname = list[1].to_s.strip user = User.find(prefix + list[0].to_s.strip)
user.nickname = list[1].to_s.strip if user
user.professional_certification = 1
user.certification = 1
user.grade = 0
user.password = "12345678"
user.phone = list[5].blank? ? nil : list[5]
if user.save
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)) 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 if list[3] && list[3].to_i == 0
ue.technical_title = ["教授", "副教授", "讲师", "助教"].include?(list[4]) ? list[4] : "讲师" ue.technical_title = ["教授", "副教授", "讲师", "助教"].include?(list[4]) ? list[4] : "讲师"

@ -1,6 +1,6 @@
class CourseGroup < ActiveRecord::Base class CourseGroup < ActiveRecord::Base
# attr_accessible :title, :body # attr_accessible :title, :body
belongs_to :course belongs_to :course, :counter_cache => true
has_many :course_members has_many :course_members
has_many :members has_many :members
has_many :memberships, :class_name => 'Member' has_many :memberships, :class_name => 'Member'

@ -300,7 +300,7 @@ class User < Principal
attr_accessor :password, :password_confirmation attr_accessor :password, :password_confirmation
attr_accessor :last_before_login_on attr_accessor :last_before_login_on
# Prevents unauthorized assignments # Prevents unauthorized assignments
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password # attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
LOGIN_LENGTH_LIMIT = 30 LOGIN_LENGTH_LIMIT = 30
MAIL_LENGTH_LIMIT = 60 MAIL_LENGTH_LIMIT = 60
@ -308,15 +308,15 @@ class User < Principal
#validates_presence_of :login, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) } #validates_presence_of :login, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
validates_presence_of :login, :if => Proc.new { |user| !user.is_a?(AnonymousUser) } validates_presence_of :login, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, :case_sensitive => false validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, :case_sensitive => false
validates_uniqueness_of :mail, :if => Proc.new { |user| user.mail_changed? && user.mail.present? }, :case_sensitive => false #validates_uniqueness_of :mail, :if => Proc.new { |user| user.mail_changed? && user.mail.present? }, :case_sensitive => false
validates_uniqueness_of :phone, :if => Proc.new { |user| user.phone_changed? && user.phone.present? }, :case_sensitive => false validates_uniqueness_of :phone, :if => Proc.new { |user| user.phone_changed? && user.phone.present? }, :case_sensitive => false
# Login must contain letters, numbers, underscores only # Login must contain letters, numbers, underscores only
#validates_format_of :login, :with => /\A[a-z0-9_\-]*\z/i #validates_format_of :login, :with => /\A[a-z0-9_\-]*\z/i
validates_length_of :login, :maximum => LOGIN_LENGTH_LIMIT validates_length_of :login, :maximum => LOGIN_LENGTH_LIMIT
validates_length_of :firstname, :maximum => 30 validates_length_of :firstname, :maximum => 30
validates_length_of :lastname, :maximum => 30 validates_length_of :lastname, :maximum => 30
validates_format_of :mail, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :allow_blank => true #validates_format_of :mail, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :allow_blank => true
validates_length_of :mail, :maximum => MAIL_LENGTH_LIMIT, :allow_nil => true #validates_length_of :mail, :maximum => MAIL_LENGTH_LIMIT, :allow_nil => true
validates_confirmation_of :password, :allow_nil => true validates_confirmation_of :password, :allow_nil => true
# validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true # validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
validate :validate_password_length validate :validate_password_length
@ -673,9 +673,9 @@ class User < Principal
base_reload(*args) base_reload(*args)
end end
def mail=(arg) # def mail=(arg)
write_attribute(:mail, arg.to_s.strip) # write_attribute(:mail, arg.to_s.strip)
end # end
def identity_url=(url) def identity_url=(url)
if url.blank? if url.blank?

Loading…
Cancel
Save