hps_member/app/models/hps_member.rb

53 lines
1.2 KiB
Ruby
Raw Normal View History

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:14:19 +00:00
# validates :password, :on => [:create]
2017-05-18 12:12:35 +00:00
has_many :hps_files, :dependent => :destroy
has_many :hps_results, :dependent => :destroy
has_many :hps_counseling_records, :dependent => :destroy
2017-05-18 12:12:35 +00:00
def get_user_type
case self.user_type
when 0
2017-08-18 08:15:21 +00:00
I18n.t("member_counselor.type1") #school
2017-05-18 12:12:35 +00:00
when 1
2017-08-18 08:15:21 +00:00
I18n.t("member_counselor.type2") #govt
2017-05-18 12:12:35 +00:00
when 2
2017-08-18 08:15:21 +00:00
I18n.t("member_counselor.type3") #counselor
2017-05-18 12:12:35 +00:00
end
end
end