From: Tomas Sedovic <tsedovic(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=640257
Previously, pressing the Reset button saved the entered input instead of
resetting the previous values.
---
src/app/controllers/cloud_accounts_controller.rb | 48 +++++++++++----------
1 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/src/app/controllers/cloud_accounts_controller.rb
b/src/app/controllers/cloud_accounts_controller.rb
index 9d75347..c8e94fe 100644
--- a/src/app/controllers/cloud_accounts_controller.rb
+++ b/src/app/controllers/cloud_accounts_controller.rb
@@ -71,31 +71,33 @@ class CloudAccountsController < ApplicationController
end
def update_accounts
- params[:cloud_accounts].each do |id, attributes|
- @cloud_account = CloudAccount.find(id)
- require_privilege(Privilege::ACCOUNT_MODIFY, @cloud_account.provider)
+ if params[:update_cloud_accounts]
+ params[:cloud_accounts].each do |id, attributes|
+ @cloud_account = CloudAccount.find(id)
+ require_privilege(Privilege::ACCOUNT_MODIFY, @cloud_account.provider)
- # blank password means the user didn't change it -- don't update it then
- if attributes.has_key? :password and String(attributes[:password]).empty?
- attributes.delete :password
- end
- @cloud_account.quota.maximum_running_instances =
quota_from_string(params[:quota][id][:maximum_running_instances])
- private_cert = attributes[:x509_cert_priv_file]
- if private_cert.nil?
- attributes.delete :x509_cert_priv
- else
- attributes[:x509_cert_priv] = private_cert.read
- attributes.delete :x509_cert_priv_file
- end
- public_cert = attributes[:x509_cert_pub_file]
- if public_cert.nil?
- attributes.delete :x509_cert_pub
- else
- attributes[:x509_cert_pub] = public_cert.read
- attributes.delete :x509_cert_pub_file
+ # blank password means the user didn't change it -- don't update it then
+ if attributes.has_key? :password and String(attributes[:password]).empty?
+ attributes.delete :password
+ end
+ @cloud_account.quota.maximum_running_instances =
quota_from_string(params[:quota][id][:maximum_running_instances])
+ private_cert = attributes[:x509_cert_priv_file]
+ if private_cert.nil?
+ attributes.delete :x509_cert_priv
+ else
+ attributes[:x509_cert_priv] = private_cert.read
+ attributes.delete :x509_cert_priv_file
+ end
+ public_cert = attributes[:x509_cert_pub_file]
+ if public_cert.nil?
+ attributes.delete :x509_cert_pub
+ else
+ attributes[:x509_cert_pub] = public_cert.read
+ attributes.delete :x509_cert_pub_file
+ end
+ @cloud_account.update_attributes!(attributes)
+ @cloud_account.quota.save!
end
- @cloud_account.update_attributes!(attributes)
- @cloud_account.quota.save!
end
redirect_to :controller => 'provider', :action => 'accounts',
:id => params[:provider][:id]
end
--
1.7.2.3