Sha256: 04bf25e0c090161e8dc3216c7f02af7da41823fbe88febcfe9dd4c176d00ff82

Contents?: true

Size: 797 Bytes

Versions: 2

Compression:

Stored size: 797 Bytes

Contents

module CamaleonCms
  class Theme < CamaleonCms::TermTaxonomy
    include CamaleonCms::CommonRelationships

    # 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

2 entries across 2 versions & 1 rubygems

Version Path
camaleon_cms-2.7.2 app/models/camaleon_cms/theme.rb
camaleon_cms-2.7.1 app/models/camaleon_cms/theme.rb