Sha256: bb7ac5aedf3d0b3d7f290f6932239560fdb4e1bf9746b5fd75871db6663416d5

Contents?: true

Size: 1.17 KB

Versions: 38

Compression:

Stored size: 1.17 KB

Contents

module ForemanOpenscap
  module HostsControllerExtensions
    def self.prepended(base)
      base::AJAX_REQUESTS << 'openscap_proxy_changed'
    end

    def process_hostgroup
      @hostgroup = Hostgroup.find(params[:host][:hostgroup_id]) if params[:host][:hostgroup_id].to_i > 0
      return head(:not_found) unless @hostgroup
      @openscap_proxy = @hostgroup.openscap_proxy
      super
    end

    def select_multiple_openscap_proxy
      find_multiple
    end

    def update_multiple_openscap_proxy
      if (id = params['smart_proxy']['id'])
        find_multiple
        smart_proxy = ::SmartProxy.find(id)
        @hosts.each do |host|
          host.openscap_proxy = smart_proxy
          host.save!
        end
        success _("Updated hosts: Assigned with OpenSCAP Proxy: %s") % smart_proxy.name
        redirect_to hosts_path
      else
        error _('No OpenSCAP Proxy selected.')
        redirect_to(select_multiple_openscap_proxy_hosts_path)
      end
    end

    private

    def action_permission
      case params[:action]
      when 'select_multiple_openscap_proxy', 'update_multiple_openscap_proxy'
        :edit
      else
        super
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
foreman_openscap-4.1.3 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-4.0.6 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-4.2.0 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-4.0.5 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-4.1.2 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-4.1.1 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-4.1.0 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-4.0.4 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-4.0.3 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-4.0.2 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-4.0.1 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-3.0.1 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-4.0.0 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-3.0.0 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-2.0.2 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-1.0.10 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-2.0.1 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-1.0.9 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-2.0.0 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
foreman_openscap-1.0.8 app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb