Class: ForemanVirtWhoConfigure::ConfigsController
Instance Method Summary
collapse
#resource_class, #resource_name
Instance Method Details
#auto_complete_controller_name ⇒ Object
71
72
73
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 71
def auto_complete_controller_name
'foreman_virt_who_configure_configs'
end
|
#config_params ⇒ Object
compatibility layer for 1.11 - pre strong params patch
80
81
82
83
84
85
86
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 80
def config_params
if defined?(super)
super
else
params[:foreman_virt_who_configure_config]
end
end
|
#controller_name ⇒ Object
75
76
77
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 75
def controller_name
'foreman_virt_who_configure_configs'
end
|
#controller_permission ⇒ Object
88
89
90
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 88
def controller_permission
'virt_who_config'
end
|
#create ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 36
def create
@config = Config.new(config_params)
if @config.save
process_success :success_redirect => foreman_virt_who_configure_config_path(@config), :object => @config.name
else
render 'new'
end
end
|
#deploy_script ⇒ Object
67
68
69
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 67
def deploy_script
send_data @config.virt_who_bash_script, :filename => "deploy_virt_who_config_#{@config.id}.sh", :type => 'text/x-shellscript', :disposition => :attachment
end
|
#destroy ⇒ Object
59
60
61
62
63
64
65
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 59
def destroy
if @config.destroy
process_success :object => @config.name
else
process_error :object => @config.name
end
end
|
#edit ⇒ Object
48
49
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 48
def edit
end
|
#index ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 16
def index
if respond_to?(:resource_base_search_and_page)
@configs = resource_base_search_and_page
else
base = resource_base.search_for(params[:search], :order => params[:order])
@configs = base.paginate(:page => params[:page], :per_page => params[:per_page])
end
@configs = apply_organization_filter(@configs)
end
|
#new ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 26
def new
@config = Config.new
if params.key?(:organization_id)
@config.organization = Organization.authorized(:view_organizations).where(:id => params[:organization_id]).first
end
@config.hypervisor_type ||= Config::HYPERVISOR_DEFAULT_TYPE
@config.organization ||= Organization.current
@config.satellite_url ||= URI.parse(Setting[:foreman_url]).host
end
|
#show ⇒ Object
45
46
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 45
def show
end
|
#update ⇒ Object
51
52
53
54
55
56
57
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 51
def update
if @config.update(config_params)
process_success :object => @config.name
else
process_error :object => @config.name
end
end
|
#welcome ⇒ Object
in 1.11 we can’t use welcome from application controller since it does not work with namespaces
8
9
10
11
12
13
14
|
# File 'app/controllers/foreman_virt_who_configure/configs_controller.rb', line 8
def welcome
scope = apply_organization_filter(model_of_controller)
if scope.first.nil?
@welcome = true
render :action => :welcome
end
end
|