2020-03-09 00:40:16 +08:00
|
|
|
class UserExtension < ApplicationRecord
|
|
|
|
# identity 0: 教师教授 1: 学生, 2: 专业人士, 3: 开发者
|
|
|
|
enum identity: { teacher: 0, student: 1, professional: 2, developer: 3, enterprise: 4, unselect: -1 }
|
|
|
|
|
|
|
|
belongs_to :user, touch: true
|
2020-03-13 14:17:12 +08:00
|
|
|
# belongs_to :school, optional: true
|
|
|
|
# belongs_to :department, optional: true
|
2020-03-09 00:40:16 +08:00
|
|
|
|
2020-03-13 14:17:12 +08:00
|
|
|
# before_save :set_laboratory_school
|
2020-03-09 00:40:16 +08:00
|
|
|
|
|
|
|
def identity_text
|
|
|
|
I18n.t("user.identity.#{identity}")
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_laboratory_school
|
2020-03-11 20:01:44 +08:00
|
|
|
# return unless new_record?
|
2020-03-09 00:40:16 +08:00
|
|
|
|
2020-03-11 20:01:44 +08:00
|
|
|
# self.school_id = Laboratory.current.school_id if school_id.blank? && !Laboratory.current.main_site?
|
2020-03-09 00:40:16 +08:00
|
|
|
end
|
|
|
|
end
|