Sha256: 6f969acb932e71b136e4e3ad76ce063df354bd5add2d70af0d2dd6fc211f1812

Contents?: true

Size: 566 Bytes

Versions: 1

Compression:

Stored size: 566 Bytes

Contents

# Make templates supplied by the plugin read-only so they can be safely
# replaced during DB migrations.
module Bootdisk::ConfigTemplateExt
  extend ActiveSupport::Concern

  included do
    before_destroy :bootdisk_destroy?
    validate :bootdisk_readonly
  end

  def bootdisk_destroy?
    bootdisk_readonly
    errors.empty?
  end

  def bootdisk_readonly
    if ['Boot disk gPXE - host'].include? name_was
      errors.add(:base, _("Template is read-only as it's supplied in foreman_bootdisk.  Please copy it to a new template to customize."))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_bootdisk-1.0.0 app/models/concerns/bootdisk/config_template_ext.rb