Class: ConfigTemplatesController

Inherits:
ApplicationController show all
Includes:
Foreman::Controller::AutoCompleteSearch, Foreman::Renderer
Defined in:
app/controllers/config_templates_controller.rb

Instance Method Summary collapse

Methods included from Foreman::Renderer

#foreman_url, #render_safe, #snippet, #snippets, #unattended_render, #unattended_render_to_temp_file

Methods included from Foreman::Controller::AutoCompleteSearch

#auto_complete_search, #invalid_search_query

Methods inherited from ApplicationController

#api_request?, #welcome

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#build_pxe_defaultObject


70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/controllers/config_templates_controller.rb', line 70

def build_pxe_default
  status, msg = ConfigTemplate.build_pxe_default(self)

  respond_to do |format|
    format.html do
      status == 200 ? notice(msg) : error(msg)
      redirect_to :back
    end
    format.json do
      render :json => msg, :status => status
    end
  end
end

#createObject


36
37
38
39
40
41
42
43
# File 'app/controllers/config_templates_controller.rb', line 36

def create
  @config_template = ConfigTemplate.new(params[:config_template])
  if @config_template.save
    process_success
  else
    process_error
  end
end

#destroyObject


62
63
64
65
66
67
68
# File 'app/controllers/config_templates_controller.rb', line 62

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

#editObject


45
46
# File 'app/controllers/config_templates_controller.rb', line 45

def edit
end

#indexObject


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/config_templates_controller.rb', line 9

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

  respond_to do |format|
    format.html do
      @config_templates = values.paginate(:page => params[:page]).includes(:template_kind, :template_combinations => [:hostgroup, :environment])
    end
    format.json { render :json => values}
  end
end

#newObject


25
26
27
# File 'app/controllers/config_templates_controller.rb', line 25

def new
  @config_template = ConfigTemplate.new
end

#revisionObject


57
58
59
60
# File 'app/controllers/config_templates_controller.rb', line 57

def revision
  audit = Audit.find(params[:version])
  render :json => audit.revision.template
end

#showObject


29
30
31
32
33
34
# File 'app/controllers/config_templates_controller.rb', line 29

def show
  respond_to do |format|
    format.html { return not_found }
    format.json { render :json => @config_template }
  end
end

#updateObject


48
49
50
51
52
53
54
55
# File 'app/controllers/config_templates_controller.rb', line 48

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