Sha256: 9dc647cba8533b98d86726ba1b427ed077bae64a6aef54cbc0bddecdf7b558bb

Contents?: true

Size: 825 Bytes

Versions: 1

Compression:

Stored size: 825 Bytes

Contents

module ForemanBootdisk::HostsControllerExt
  extend ActiveSupport::Concern

  included do
    alias_method :find_by_name_bootiso, :find_by_name
    before_filter :find_by_name_bootiso, :only => %w[bootdisk_iso]
    alias_method_chain :current_permission, :bootdisk if method_defined?(:current_permission)
  end

  def bootdisk_iso
    begin
      tmpl = @host.bootdisk_template_render
    rescue => e
      error _('Failed to render boot disk template: %s') % e
      redirect_to :back
      return
    end

    ForemanBootdisk::ISOGenerator.new(tmpl).generate do |iso|
      send_data File.read(iso), :filename => "#{@host.name}.iso"
    end
  end

  def current_permission_with_bootdisk
    if params[:action] == 'bootdisk_iso'
      'download_bootdisk'
    else
      current_permission_without_bootdisk
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_bootdisk-3.0.0 app/controllers/concerns/foreman_bootdisk/hosts_controller_ext.rb