Sha256: ab19b764c44e6265e84ffb272b2bcd67a8d851bc1d3c2c7aff9b0e348d1ea92c

Contents?: true

Size: 1.5 KB

Versions: 16

Compression:

Stored size: 1.5 KB

Contents

class AddThemePreference
  
  def self.up
    if PreferenceType.find_by_internal_identifier('extjs_theme').nil?
      extjs_theme_pt = PreferenceType.create(:description => 'Theme', :internal_identifier => 'extjs_theme')

      access_extjs_theme_po = PreferenceOption.create(:description => 'Access', :internal_identifier => 'access_extjs_theme', :value => 'ext-all-access.css')
      gray_extjs_theme_po   = PreferenceOption.create(:description => 'Gray', :internal_identifier => 'gray_extjs_theme', :value => 'ext-all-gray.css')
      blue_extjs_theme_po   = PreferenceOption.create(:description => 'Blue', :internal_identifier => 'blue_extjs_theme', :value => 'ext-all.css')

      extjs_theme_pt.preference_options << access_extjs_theme_po
      extjs_theme_pt.preference_options << gray_extjs_theme_po
      extjs_theme_pt.preference_options << blue_extjs_theme_po
      extjs_theme_pt.default_preference_option = blue_extjs_theme_po
      extjs_theme_pt.save

      User.all.each do |user|
        desktop = user.desktop

        theme_pt = PreferenceType.iid('extjs_theme')
        theme_pt.preferenced_records << desktop
        theme_pt.save

        pref = Preference.create(
          :preference_type => theme_pt,
          :preference_option => PreferenceOption.iid('blue_extjs_theme')
        )

        desktop.user_preferences << UserPreference.create(
          :user => user,
          :preference => pref
        )

        desktop.save
      end
    end
  end
  
  def self.down
    #remove data here
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
erp_app-3.0.16 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.15 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.14 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.13 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.12 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.10 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.9 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.8 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.7 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.6 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.5 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.4 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.3 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.2 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.1 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb
erp_app-3.0.0 db/data_migrations/upgrade/20111212205027_add_theme_preference.rb