Sha256: 9ddfe4f26df1b6be67f3cab53e5083b05c455f827291ce09afd8e3ff50124306

Contents?: true

Size: 846 Bytes

Versions: 12

Compression:

Stored size: 846 Bytes

Contents

# A skin is a master template containing all sub templates and css to render a full site or sectioon
# of a site.
class Skin < Section
  before_save :set_need_skin_name_update
  after_save  :update_skin_name

  private

    def set_need_skin_name_update
      @need_skin_name_update = !new_record? && name_changed?
      true # save can continue
    end

    def update_skin_name
      return unless @need_skin_name_update
      # FIXME: when moving a template or a page that is a parent of a template: we must sync skin_name after spread_project_and_section.
      Skin.connection.execute "UPDATE template_contents SET skin_name = #{Zena::Db.quote(name)} WHERE template_contents.node_id IN (SELECT id FROM nodes WHERE nodes.section_id = #{Zena::Db.quote(self[:id])}) AND template_contents.site_id = #{Zena::Db.quote(self[:site_id])}"
    end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
zena-0.16.9 app/models/skin.rb
zena-0.16.8 app/models/skin.rb
zena-0.16.7 app/models/skin.rb
zena-0.16.6 app/models/skin.rb
zena-0.16.5 app/models/skin.rb
zena-0.16.4 app/models/skin.rb
zena-0.16.3 app/models/skin.rb
zena-0.16.2 app/models/skin.rb
zena-0.16.1 app/models/skin.rb
zena-0.16.0 app/models/skin.rb
zena-0.15.2 app/models/skin.rb
zena-0.15.1 app/models/skin.rb