2017-05-18 12:12:35 +00:00
|
|
|
class HpsMember
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
include ActiveModel::SecurePassword
|
|
|
|
|
|
|
|
# commmon values
|
|
|
|
|
|
|
|
field :account
|
|
|
|
field :password_digest, type: String
|
|
|
|
field :name
|
|
|
|
field :title
|
|
|
|
field :telephone
|
|
|
|
field :mobile
|
|
|
|
field :hps_city_id
|
|
|
|
field :hps_county_id
|
|
|
|
field :address
|
|
|
|
field :email
|
|
|
|
field :score, type: Integer, :default => 0
|
|
|
|
field :enabled, :type => Boolean, :default => true
|
|
|
|
field :user_type, type: Integer
|
2017-05-24 08:57:46 +00:00
|
|
|
field :old_id
|
2017-05-18 12:12:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
# school type
|
|
|
|
field :hps_school_id
|
|
|
|
|
|
|
|
# counselor type
|
|
|
|
field :affilated_committees, type: Array, :default => []
|
|
|
|
field :organization
|
|
|
|
field :responsible_counties, type: Array, :default => []
|
|
|
|
field :year, type: Array, :default => []
|
|
|
|
|
|
|
|
|
|
|
|
has_secure_password
|
|
|
|
|
|
|
|
validates :account, uniqueness: true
|
2017-05-24 09:12:33 +00:00
|
|
|
validates :password, :on => [:create]
|
2017-05-18 12:12:35 +00:00
|
|
|
|
|
|
|
has_many :hps_files, :dependent => :destroy
|
|
|
|
|
|
|
|
def get_user_type
|
|
|
|
case self.user_type
|
|
|
|
when 0
|
|
|
|
I18n.t("member_counselor.type1")
|
|
|
|
when 1
|
|
|
|
I18n.t("member_counselor.type2")
|
|
|
|
when 2
|
|
|
|
I18n.t("member_counselor.type3")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|