Sha256: a3f9d9dce3043b85585514b4e436bf5b0a3a6b7b29028c7891bee5259fde7255

Contents?: true

Size: 751 Bytes

Versions: 8

Compression:

Stored size: 751 Bytes

Contents

module CamaleonCms
  class Theme < CamaleonCms::TermTaxonomy
    # attrs:
    #   slug => plugin key
    belongs_to :site, class_name: 'CamaleonCms::Site', foreign_key: :parent_id, required: false

    default_scope { where(taxonomy: :theme) }

    before_validation :fix_name
    before_destroy :destroy_custom_fields

    # return theme settings configured in config.json
    def settings
      PluginRoutes.theme_info(slug)
    end

    # return the path to the settings file for current theme
    def settings_file
      File.join(settings['path'], 'views/admin/settings').to_s
    end

    private

    def fix_name
      self.name = slug if name.blank?
    end

    def destroy_custom_fields
      get_field_groups.destroy_all
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
camaleon_cms-2.8.3 app/models/camaleon_cms/theme.rb
camaleon_cms-2.8.2 app/models/camaleon_cms/theme.rb
camaleon_cms-2.8.1 app/models/camaleon_cms/theme.rb
camaleon_cms-2.8.0 app/models/camaleon_cms/theme.rb
camaleon_cms-2.7.5 app/models/camaleon_cms/theme.rb
camaleon_cms-2.7.4 app/models/camaleon_cms/theme.rb
camaleon_cms-2.7.3 app/models/camaleon_cms/theme.rb
camaleon_cms-2.7.0 app/models/camaleon_cms/theme.rb