42 lines
1.4 KiB
Ruby
42 lines
1.4 KiB
Ruby
class OlympiaStudentDataField
|
|
include Mongoid::Document
|
|
include Mongoid::Timestamps
|
|
include OrbitModel::Status
|
|
include OrbitModel::Impression
|
|
# encoding: utf-8
|
|
include OrbitTag::Taggable
|
|
include OrbitCategory::Categorizable
|
|
field :StudentIdentity , type: String , default: ''
|
|
field :StudentName , type: String , default: ''
|
|
field :StudentSex , type: String , default: ''
|
|
field :StudentIDNO , type: String , default: ''
|
|
field :StudentBirthYear , type: Fixnum , default: Time.now.year
|
|
field :StudentBirthMonth , type: Fixnum , default: Time.now.month
|
|
field :StudentBirthDay , type: Fixnum , default: Time.now.day
|
|
field :StudentClass , type: String , default: ''
|
|
field :StudentPhone , type: String , default: ''
|
|
field :StudentCode , type: String , default: ''
|
|
field :StudentAddress , type: String , default: ''
|
|
field :StudentArea , type: String , default: ''
|
|
field :remove_image , type: Boolean , default: false
|
|
field :approved , type: Boolean , default: true
|
|
field :olympia_school_data_fields_id , type: String , default: ''
|
|
field :sign_up_setting_id , type: String , default: ''
|
|
has_many :olympia_student_images , :dependent => :destroy , autosave: true
|
|
after_save :check_file
|
|
after_initialize do
|
|
if !self.new_record?
|
|
if self.approved.nil?
|
|
self.approved = true
|
|
self.save!
|
|
end
|
|
end
|
|
end
|
|
def check_file
|
|
if self.remove_image
|
|
self.olympia_student_images = []
|
|
self.remove_image = false
|
|
self.save
|
|
end
|
|
end
|
|
end |