34 lines
1.4 KiB
Ruby
34 lines
1.4 KiB
Ruby
class SignUpSetting
|
|
include Mongoid::Document
|
|
include Mongoid::Timestamps
|
|
include OrbitModel::Status
|
|
include OrbitModel::Impression
|
|
# encoding: utf-8
|
|
include OrbitTag::Taggable
|
|
include OrbitCategory::Categorizable
|
|
field :start_year , type: String , default: Time.now.strftime("%Y")
|
|
field :end_year , type: String , default: Time.now.strftime("%Y")
|
|
field :start_month , type: String , default: Time.now.strftime("%m")
|
|
field :end_month , type: String , default: Time.now.strftime("%m")
|
|
field :start_day , type: String , default: Time.now.strftime("%d")
|
|
field :end_day , type: String , default: Time.now.strftime("%d")
|
|
field :start_o_clock , type: String , default: Time.now.strftime("%H")
|
|
field :end_o_clock , type: String , default: Time.now.strftime("%H")
|
|
field :start_minute , type: String , default: Time.now.strftime("%M")
|
|
field :end_minute , type: String , default: Time.now.strftime("%M")
|
|
field :default_password , type: String , default: ""
|
|
field :set_default_password , type: Boolean , default: false
|
|
field :remark_field , type: Hash , default: {:zh_tw=>"",:en=>""}
|
|
field :registration_instructions , type: Hash , default: {:zh_tw=>"",:en=>""}
|
|
after_save :change_all_password
|
|
def change_all_password
|
|
if self.set_default_password
|
|
OlympiaSchoolDataFields.all.each do |school_field|
|
|
school_field.password = self.default_password
|
|
school_field.save
|
|
end
|
|
self.set_default_password = false
|
|
self.save
|
|
end
|
|
end
|
|
end |