diff --git a/temp_file/app/models/site.rb b/temp_file/app/models/site.rb index a842953..b41ebdd 100644 --- a/temp_file/app/models/site.rb +++ b/temp_file/app/models/site.rb @@ -62,42 +62,49 @@ class Site field :site_title_1, :type => Hash, :default=>{:zh_tw=>"主頁",:en=>"home_page"} field :is_hidden_orbit_bar , type: Boolean, :default => false field :orbit_bar_background_color , type: String, :default => "" - field :orbit_bar_text_color , type: String, :default => "" + field :orbit_bar_text_color , type: String, :default => "#ffffff" field :orbit_bar_submenu_background_color , type: String, :default => "" - field :orbit_bar_submenu_text_color , type: String, :default => "" + field :orbit_bar_submenu_text_color , type: String, :default => "#ffffff" field :orbit_bar_animation_time , type: String, :default => "0.3s" + field :login_text , type: String, :default => "", localize: true mount_uploader :default_image, ImageUploader mount_uploader :site_logo, ImageUploader mount_uploader :site_logo_1, ImageUploader mount_uploader :favicon, ImageUploader mount_uploader :mobile_icon, ImageUploader - after_initialize do - if !self.new_record? - if self.is_hidden_orbit_bar.nil? - self.is_hidden_orbit_bar = false - self.save - end - if self.orbit_bar_background_color.nil? - self.orbit_bar_background_color = "" - self.save - end - if self.orbit_bar_text_color.nil? - self.orbit_bar_text_color = "" - self.save - end - if self.orbit_bar_submenu_background_color.nil? - self.orbit_bar_submenu_background_color = "" - self.save - end - if self.orbit_bar_submenu_text_color.nil? - self.orbit_bar_submenu_text_color = "" - self.save - end - if self.orbit_bar_animation_time.nil? - self.orbit_bar_animation_time = "0.3s" - self.save - end - end + after_initialize do |record| + if !record.new_record? + if record.is_hidden_orbit_bar.nil? + record.is_hidden_orbit_bar = false + record.save + end + if record.orbit_bar_background_color.nil? + record.orbit_bar_background_color = "" + record.save + end + if record.orbit_bar_text_color.nil? + record.orbit_bar_text_color = "" + record.save + end + if record.orbit_bar_submenu_background_color.nil? + record.orbit_bar_submenu_background_color = "" + record.save + end + if record.orbit_bar_submenu_text_color.nil? + record.orbit_bar_submenu_text_color = "" + record.save + end + if record.orbit_bar_animation_time.nil? + record.orbit_bar_animation_time = "0.3s" + record.save + end + end + if record.orbit_bar_background_color == '#000000' && record.orbit_bar_text_color == '#000000' + record.update(:orbit_bar_text_color => '#ffffff') + end + if record.orbit_bar_submenu_background_color == '#000000' && record.orbit_bar_submenu_text_color == '#000000' + record.update(:orbit_bar_submenu_text_color => '#ffffff') + end end def register_site(url,university,department,email,country) api_key = STORE_CONFIG[:store_settings]["api_key"]