[PATCH conductor 3/3] Adds XML format for Provider Accounts API - update
pblaho at redhat.com
pblaho at redhat.com
Wed Aug 15 22:08:06 UTC 2012
From: Petr Blaho <pblaho at redhat.com>
https://www.aeolusproject.org/redmine/issues/3692
Adds block for XML format.
Adds handling of credentials param
Adds route to create action
---
.../controllers/provider_accounts_controller.rb | 27 +++++++++++++++----
src/config/routes.rb | 2 +-
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/src/app/controllers/provider_accounts_controller.rb b/src/app/controllers/provider_accounts_controller.rb
index eaa7c0f..3508ee8 100644
--- a/src/app/controllers/provider_accounts_controller.rb
+++ b/src/app/controllers/provider_accounts_controller.rb
@@ -127,18 +127,33 @@ class ProviderAccountsController < ApplicationController
require_privilege(Privilege::MODIFY, at provider_account)
@quota = @provider_account.quota
@providers = Provider.find(:all)
-
limit = params[:quota][:maximum_running_instances] if params[:quota]
@provider_account.quota.set_maximum_running_instances(limit)
- credentials_hash = params[:provider_account].delete(:credentials_hash)
+ credentials_hash = if params[:provider_account][:credentials]
+ params[:provider_account].delete( :credentials )
+ elsif params[:provider_account][:credentials_hash]
+ params[:provider_account].delete( :credentials_hash )
+ else
+ nil
+ end
@provider_account.attributes = params[:provider_account]
@provider_account.credentials_hash= credentials_hash
if @provider_account.save
- flash[:notice] = t"provider_accounts.flash.notice.updated"
- redirect_to edit_provider_path(@provider, :details_tab => 'accounts')
+ respond_to do |format|
+ format.html do
+ flash[:notice] = t"provider_accounts.flash.notice.updated"
+ redirect_to edit_provider_path(@provider, :details_tab => 'accounts')
+ end
+ format.xml { render 'show', :locals => { :provider_account => @provider_account, :with_credentials => true, :with_quota => true }, :status => :ok }
+ end
else
- flash[:error] = t"provider_accounts.flash.error.not_updated"
- render :action => :edit
+ respond_to do |format|
+ format.html do
+ flash[:error] = t"provider_accounts.flash.error.not_updated"
+ render :action => :edit
+ end
+ format.xml { render 'api/validation_error', :locals => { :errors => @provider_account.errors }, :status => :bad_request }
+ end
end
end
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 73d7aaa..fa533c4 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -292,7 +292,7 @@ Conductor::Application.routes.draw do
resources :providers, :only => [:index, :show, :create, :update, :destroy] do
resources :provider_accounts, :only => [:index]
end
- resources :provider_accounts, :only => [:index, :show, :destroy]
+ resources :provider_accounts, :only => [:index, :show, :update, :destroy]
resources :provider_types, :only => [:index, :show]
resources :hardware_profiles, :only => [:index, :show, :destroy, :create]
resources :pools, :only => [:index, :show, :create, :update, :destroy]
--
1.7.7.6
More information about the aeolus-devel
mailing list