Class: PuppetclassesController

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

Instance Method Summary collapse

Methods included from Foreman::Controller::AutoCompleteSearch

#auto_complete_search, #invalid_search_query

Methods included from Foreman::Controller::Environments

#import_environments, #obsolete_and_new

Methods inherited from ApplicationController

#api_request?, #welcome

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#createObject


31
32
33
34
35
36
37
38
39
# File 'app/controllers/puppetclasses_controller.rb', line 31

def create
  @puppetclass = Puppetclass.new(params[:puppetclass])
  if @puppetclass.save
    notice _("Successfully created puppetclass.")
    redirect_to puppetclasses_url
  else
    render :action => 'new'
  end
end

#destroyObject


53
54
55
56
57
58
59
60
# File 'app/controllers/puppetclasses_controller.rb', line 53

def destroy
  if @puppetclass.destroy
    notice _("Successfully destroyed puppetclass.")
  else
    error @puppetclass.errors.full_messages.join("<br/>")
  end
  redirect_to puppetclasses_url
end

#editObject


41
42
# File 'app/controllers/puppetclasses_controller.rb', line 41

def edit
end

#indexObject


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

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

  respond_to do |format|
    format.html do
      @puppetclasses = values.paginate(:page => params[:page])
      @host_counter = Host.count(:group => :puppetclass_id, :joins => :puppetclasses, :conditions => {:puppetclasses => {:id => @puppetclasses.all}})
      @keys_counter = Puppetclass.joins(:class_params).select('distinct environment_classes.lookup_key_id').count(:group => 'name')
    end
    format.json { render :json => Puppetclass.classes2hash(values.all(:select => "name, id")) }
  end
end

#newObject


27
28
29
# File 'app/controllers/puppetclasses_controller.rb', line 27

def new
  @puppetclass = Puppetclass.new
end

#parametersObject

form AJAX methods


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

def parameters
  puppetclass = Puppetclass.find(params[:id])
  render :partial => "puppetclasses/class_parameters", :locals => {
      :puppetclass => puppetclass,
      :obj => get_host_or_hostgroup}
end

#updateObject


44
45
46
47
48
49
50
51
# File 'app/controllers/puppetclasses_controller.rb', line 44

def update
  if @puppetclass.update_attributes(params[:puppetclass])
    notice _("Successfully updated puppetclass.")
    redirect_back_or_default(puppetclasses_url)
  else
    render :action => 'edit'
  end
end