foreman/app/controllers/operatingsystems_controller.rb @ acfbc458
9eb0e160 | Ohad Levy | class OperatingsystemsController < ApplicationController
|
|
8de14697 | Ohad Levy | include Foreman::Controller::AutoCompleteSearch
|
|
acfbc458 | Marek Hulan | before_filter :find_by_name, :only => %w{edit update destroy}
|
|
ff5ad780 | Ohad Levy | ||
66bb73ba | Ohad Levy | def index
|
|
acfbc458 | Marek Hulan | @operatingsystems = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
|
|
145db863 | Dmitri Dolguikh | @host_counter = Host.group(:operatingsystem_id).where(:operatingsystem_id => @operatingsystems.collect(&:id)).count
|
|
66bb73ba | Ohad Levy | end
|
|
def new
|
|||
@operatingsystem = Operatingsystem.new
|
|||
end
|
|||
def create
|
|||
@operatingsystem = Operatingsystem.new(params[:operatingsystem])
|
|||
if @operatingsystem.save
|
|||
b28fdce4 | Ohad Levy | process_success
|
|
66bb73ba | Ohad Levy | else
|
|
b28fdce4 | Ohad Levy | process_error
|
|
66bb73ba | Ohad Levy | end
|
|
end
|
|||
def edit
|
|||
9c3f01c5 | Ohad Levy | # Generates default OS template entries
|
|
@operatingsystem.config_templates.map(&:template_kind_id).uniq.each do |kind|
|
|||
017e1049 | Ohad Levy | if @operatingsystem.os_default_templates.where(:template_kind_id => kind).blank?
|
|
@operatingsystem.os_default_templates.build(:template_kind_id => kind)
|
|||
end
|
|||
9c3f01c5 | Ohad Levy | end if SETTINGS[:unattended]
|
|
66bb73ba | Ohad Levy | end
|
|
def update
|
|||
if @operatingsystem.update_attributes(params[:operatingsystem])
|
|||
b28fdce4 | Ohad Levy | process_success
|
|
66bb73ba | Ohad Levy | else
|
|
b28fdce4 | Ohad Levy | process_error
|
|
66bb73ba | Ohad Levy | end
|
|
end
|
|||
def destroy
|
|||
if @operatingsystem.destroy
|
|||
b28fdce4 | Ohad Levy | process_success
|
|
66bb73ba | Ohad Levy | else
|
|
b28fdce4 | Ohad Levy | process_error
|
|
66bb73ba | Ohad Levy | end
|
|
286a2207 | Ohad Levy | end
|
|
end
|