Sha256: 5142941bfeded7b1eb18ee3cc60a816242d9d5637bc9462c6ff7f45a331817c6

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

class LookupKeysController < ApplicationController
  include Foreman::Controller::AutoCompleteSearch
  before_filter :find_by_key, :except => :index
  before_filter :setup_search_options, :only => :index

  def index
    begin
      values = LookupKey.search_for(params[:search], :order => params[:order])
    rescue => e
      error e.to_s
      values = LookupKey.search_for ""
    end

    respond_to do |format|
      format.html do
        @lookup_keys = values.paginate(:page => params[:page], :include => [:puppetclass])
      end
      format.json { render :json => values}
    end
  end

  def show
    if (name = params[:host_id]).blank? or (host = Host.find_by_name(name)).blank?
      value = @lookup_key
    else
      value = { :value => @lookup_key.value_for(host) }
    end

    respond_to do |format|
      format.json { render :json => value }
    end
  end

  def edit
  end

  def update
    if @lookup_key.update_attributes(params[:lookup_key])
      process_success
    else
      process_error
    end
  end

  def destroy
    if @lookup_key.destroy
      process_success
    else
      process_error
    end
  end

  private
  def find_by_key
    if params[:id]
      @lookup_key = LookupKey.find(params[:id])
      not_found and return if @lookup_key.blank?
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/app/controllers/lookup_keys_controller.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/app/controllers/lookup_keys_controller.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/app/controllers/lookup_keys_controller.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/app/controllers/lookup_keys_controller.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/app/controllers/lookup_keys_controller.rb