Revision 6b728fdc
Added by Bash Shell about 14 years ago
- ID 6b728fdc6edbbdbb3b6fa44ad35cc34d314c8a1d
app/controllers/hosts_controller.rb | ||
---|---|---|
before_filter :ajax_methods, :only => [:environment_selected, :architecture_selected, :os_selected]
|
||
before_filter :load_tabs, :manage_tabs, :only => :index
|
||
before_filter :find_multiple, :only => [:multiple_actions, :update_multiple_parameters,
|
||
:select_multiple_hostgroup, :multiple_parameters]
|
||
:select_multiple_hostgroup, :select_multiple_environment, :multiple_parameters]
|
||
|
||
helper :hosts
|
||
|
||
... | ... | |
redirect_to(hosts_path)
|
||
end
|
||
|
||
def select_multiple_environment
|
||
end
|
||
|
||
def update_multiple_environment
|
||
# simple validations
|
||
if (id=params["environment"]["id"]).empty?
|
||
flash[:foreman_error] = 'No Environment selected!'
|
||
redirect_to(select_multiple_environment_hosts_path) and return
|
||
end
|
||
if (ev = Environment.find id).nil?
|
||
flash[:foreman_error] = 'Empty Environment selected!'
|
||
redirect_to(select_multiple_environment_hosts_path) and return
|
||
end
|
||
|
||
#update the hosts
|
||
Host.find(session[:selected]).each do |host|
|
||
host.environment=ev
|
||
host.save(perform_validation = false)
|
||
end
|
||
|
||
session[:selected] = []
|
||
flash[:foreman_notice] = 'Updated hosts: Changed Environment'
|
||
redirect_to(hosts_path)
|
||
end
|
||
|
||
# AJAX method to update our session each time a host has been selected
|
||
# we are using AJAX and JS as the user might select multiple hosts across different pages (or requests).
|
||
def save_checkbox
|
Also available in: Unified diff
Fixes #258: Change Environment for multiple hosts.