---
.../controllers/provider_accounts_controller.rb | 33 ++++++++++---------
src/app/controllers/realms_controller.rb | 2 +
src/app/views/provider_accounts/_form.haml | 2 -
src/app/views/provider_accounts/_list.haml | 2 +-
src/app/views/provider_accounts/_properties.haml | 4 +-
.../views/provider_accounts/_provider_form.haml | 2 +-
.../provider_accounts/_provider_selection.haml | 13 +++----
src/app/views/provider_accounts/edit.haml | 32 ++++++++++++-------
src/app/views/provider_accounts/new.haml | 6 ++-
src/app/views/provider_accounts/show.haml | 26 +++++++++------
src/app/views/realms/_list.haml | 2 +-
src/app/views/realms/new.haml | 2 +-
src/config/routes.rb | 14 +++-----
src/features/provider_account.feature | 14 +++++---
14 files changed, 84 insertions(+), 70 deletions(-)
diff --git a/src/app/controllers/provider_accounts_controller.rb
b/src/app/controllers/provider_accounts_controller.rb
index c48c02f..1aa424b 100644
--- a/src/app/controllers/provider_accounts_controller.rb
+++ b/src/app/controllers/provider_accounts_controller.rb
@@ -15,18 +15,17 @@ class ProviderAccountsController < ApplicationController
def show
@tab_captions = ['Properties', 'Credentials', 'History',
'Permissions']
- @account = ProviderAccount.find(params[:id])
- @account_id = @account.credentials_hash['account_id']
- require_privilege(Privilege::VIEW, @account)
+ @provider_account = ProviderAccount.find(params[:id])
+ @provider = Provider.find(params[:provider_id])
+ @account_id = @provider_account.credentials_hash['account_id']
+ require_privilege(Privilege::VIEW, @provider_account)
@details_tab = params[:details_tab].blank? ? 'properties' :
params[:details_tab]
if params.delete :test_account
- test_account(@account)
+ test_account(@provider_account)
render :action => 'show' and return
end
- save_breadcrumb(provider_account_path(@account), @account.name)
-
respond_to do |format|
format.html { render :action => 'show'}
format.js do
@@ -45,7 +44,7 @@ class ProviderAccountsController < ApplicationController
if @providers.empty?
flash[:error] = "You don't have any provider yet. Please create
one!"
else
- @selected_provider = Provider.find(params[:provider_id])
+ @provider = Provider.find(params[:provider_id])
end
end
@@ -54,12 +53,11 @@ class ProviderAccountsController < ApplicationController
provider = params[:provider_account].delete(:provider)
params[:provider_account][:provider_id] = Provider.find_by_name(provider).id
end
- @selected_provider = @provider =
Provider.find(params[:provider_account][:provider_id])
+ @provider = Provider.find(params[:provider_account][:provider_id])
require_privilege(Privilege::CREATE, ProviderAccount, @provider)
@providers = Provider.all
@provider_account = ProviderAccount.new(params[:provider_account])
- @provider_account.provider = @provider
@provider_account.quota = @quota = Quota.new
limit = params[:quota][:maximum_running_instances] if params[:quota]
@@ -71,7 +69,7 @@ class ProviderAccountsController < ApplicationController
@provider_account.assign_owner_roles(current_user)
@provider_account.populate_realms
flash[:notice] = t('provider_accounts.index.account_added', :list =>
@provider_account.name, :count => 1)
- redirect_to edit_provider_path((a)provider_account.provider, :view =>
'filter', :details_tab => 'connectivity')
+ redirect_to edit_provider_path(@provider, :view => 'filter',
:details_tab => 'connectivity')
else
flash[:error] = "Cannot add the provider account."
render :action => 'new' and return
@@ -85,6 +83,7 @@ class ProviderAccountsController < ApplicationController
def edit
@provider_account = ProviderAccount.find(params[:id])
+ @provider = Provider.find(params[:provider_id])
@selected_provider = @provider_account.provider
@quota = @provider_account.quota
@providers = Provider.find(:all)
@@ -103,7 +102,7 @@ class ProviderAccountsController < ApplicationController
@provider_account.quota.set_maximum_running_instances(limit)
if @provider_account.update_attributes(params[:provider_account])
flash[:notice] = "Provider Account updated!"
- redirect_to provider_account_path(@provider_account)
+ redirect_to edit_provider_path(@provider, :view => 'filter',
:details_tab => 'connectivity')
else
flash[:error] = "Provider Account wasn't updated!"
render :action => :edit
@@ -112,18 +111,20 @@ class ProviderAccountsController < ApplicationController
def destroy
require_privilege(Privilege::MODIFY, @provider_account)
+ @provider = Provider.find(params[:provider_id])
if ProviderAccount.destroy(params[:id])
flash[:notice] = "Provider account was deleted!"
else
flash[:error] = "Provider account was not deleted!"
end
- redirect_to provider_accounts_path
+ redirect_to edit_provider_path(@provider, :view => 'filter', :details_tab
=> 'connectivity')
end
def multi_destroy
+ @provider = Provider.find(params[:provider_id])
if params[:accounts_selected].blank?
flash[:warning] = "You must select some accounts first."
- redirect_to provider_accounts_url and return
+ redirect_to edit_provider_path(@provider, :view => 'filter',
:details_tab => 'connectivity') and return
end
succeeded = []
@@ -143,7 +144,7 @@ class ProviderAccountsController < ApplicationController
unless failed.empty?
flash[:error] = t 'provider_accounts.index.account_not_deleted', :count
=> failed.length, :list => failed.join(', ')
end
- redirect_to edit_provider_path((a)provider_accounts.first.provider, :view =>
'filter', :details_tab => 'connectivity')
+ redirect_to edit_provider_path(@provider, :view => 'filter', :details_tab
=> 'connectivity')
end
def set_selected_provider
@@ -152,12 +153,12 @@ class ProviderAccountsController < ApplicationController
respond_to do |format|
format.html {
@providers = Provider.find(:all)
- @selected_provider = Provider.find(params[:provider_account][:provider_id])
+ @provider = Provider.find(params[:provider_account][:provider_id])
render :action => 'new', :layout => true
}
format.js {
@providers = Provider.find(:all)
- @selected_provider = Provider.find(params[:provider_account][:provider_id])
+ @provider = Provider.find(params[:provider_account][:provider_id])
render :partial => 'provider_selection'
}
diff --git a/src/app/controllers/realms_controller.rb
b/src/app/controllers/realms_controller.rb
index 19bd2a9..76ea81f 100644
--- a/src/app/controllers/realms_controller.rb
+++ b/src/app/controllers/realms_controller.rb
@@ -9,6 +9,7 @@ class RealmsController < ApplicationController
def new
require_privilege(Privilege::CREATE, Realm)
+ @provider = Provider.find(params[:provider_id])
@realm = FrontendRealm.new
load_backend_realms
end
@@ -38,6 +39,7 @@ class RealmsController < ApplicationController
def create
require_privilege(Privilege::CREATE, Realm)
+ @provider = Provider.find(params[:provider_id])
@realm = FrontendRealm.new(params[:frontend_realm])
if @realm.save
flash[:notice] = "Realm was added."
diff --git a/src/app/views/provider_accounts/_form.haml
b/src/app/views/provider_accounts/_form.haml
index df66ac9..cf5137b 100644
--- a/src/app/views/provider_accounts/_form.haml
+++ b/src/app/views/provider_accounts/_form.haml
@@ -1,4 +1,2 @@
- error_messages_for @provider_account
= render :partial => 'provider_selection'
-%fieldset.options
- = form.submit 'Save', :class => "button"
diff --git a/src/app/views/provider_accounts/_list.haml
b/src/app/views/provider_accounts/_list.haml
index e88d5b1..4223baa 100644
--- a/src/app/views/provider_accounts/_list.haml
+++ b/src/app/views/provider_accounts/_list.haml
@@ -1,6 +1,6 @@
.content
- content_for :form_header do
- %li= restful_submit_tag "Delete Selected", "destroy",
multi_destroy_provider_accounts_path, 'DELETE', :id => 'delete_button',
:class => 'button pill danger'
+ %li= restful_submit_tag "Delete Selected", "destroy",
multi_destroy_provider_provider_accounts_path(@provider), 'DELETE', :id =>
'delete_button', :class => 'button pill danger'
%li= link_to "New Account", new_provider_provider_account_path(@provider),
:id => 'new_provider_account', :class => 'button pill'
= filter_table(provider_accounts_header, @provider_accounts) do |account|
diff --git a/src/app/views/provider_accounts/_properties.haml
b/src/app/views/provider_accounts/_properties.haml
index 559bdf1..60aef58 100644
--- a/src/app/views/provider_accounts/_properties.haml
+++ b/src/app/views/provider_accounts/_properties.haml
@@ -3,14 +3,14 @@
%tr
%th.show
Properties for
- = @account.name
+ = @provider_account.name
%th.show
%tbody
%tr
%td
%label Running instances quota:
%td
- = @account.quota.maximum_running_instances or 'unlimited'
+ = @provider_account.quota.maximum_running_instances or 'unlimited'
- if @account_id
%tr
%td
diff --git a/src/app/views/provider_accounts/_provider_form.haml
b/src/app/views/provider_accounts/_provider_form.haml
index 35e2520..93b6222 100644
--- a/src/app/views/provider_accounts/_provider_form.haml
+++ b/src/app/views/provider_accounts/_provider_form.haml
@@ -3,7 +3,7 @@
= label :provider_account, "Account Name"
= text_field :provider_account, :label, :class => 'em long'
- CredentialDefinition::CREDENTIAL_DEFINITIONS_ORDER.each do |cred_order|
- - @provider_account.all_credentials((a)selected_provider).each do |cred|
+ - @provider_account.all_credentials((a)provider).each do |cred|
- if cred_order == cred.credential_definition.name
%fieldset
%p
diff --git a/src/app/views/provider_accounts/_provider_selection.haml
b/src/app/views/provider_accounts/_provider_selection.haml
index 068c1c3..34d4f10 100644
--- a/src/app/views/provider_accounts/_provider_selection.haml
+++ b/src/app/views/provider_accounts/_provider_selection.haml
@@ -1,14 +1,14 @@
%fieldset#provider_type
%p
= label_tag "Provider"
- = select(:provider_account, :provider_id, options_for_select((a)providers.map{ |p|
[p.name, p.id] }, :selected => @selected_provider.id))
- = restful_submit_tag "Choose",
'set_selected_provider',set_selected_provider_provider_accounts_path,
'GET', :class => 'button'
+ = select(:provider_account, :provider_id, options_for_select((a)providers.map{ |p|
[p.name, p.id] }, :selected => @provider.id))
+ = restful_submit_tag "Choose",
'set_selected_provider',set_selected_provider_provider_provider_accounts_path(@provider),
'GET', :class => 'button pill'
%p
= label_tag "Cloud type: "
- = @selected_provider.provider_type.name
+ = @provider.provider_type.name
.clear
- - unless @selected_provider.provider_type.deltacloud_driver.nil?
- = render :partial => "provider_form", :locals => { :provider_type
=> @selected_provider.provider_type}
+ - unless @provider.provider_type.deltacloud_driver.nil?
+ = render :partial => "provider_form", :locals => { :provider_type
=> @provider.provider_type}
- else
= flash.now[:warning] = "You don't have any provider yet"
@@ -18,11 +18,10 @@
$("#provider_account_provider_id").change(function()
{
selected_provider =
$(this).find("option:selected").attr('value');
- $.get("#{set_selected_provider_provider_accounts_url}",
{'provider_account[provider_id]':selected_provider},
+
$.get("#{set_selected_provider_provider_provider_accounts_url(@provider)}",
{'provider_account[provider_id]':selected_provider},
function(result) {
$("#provider_type").html(result);
}
);
-
});
});
diff --git a/src/app/views/provider_accounts/edit.haml
b/src/app/views/provider_accounts/edit.haml
index 2abd583..71d15ee 100644
--- a/src/app/views/provider_accounts/edit.haml
+++ b/src/app/views/provider_accounts/edit.haml
@@ -1,19 +1,27 @@
= render :partial => 'layouts/admin_nav'
-%header.page-header
- %h1{:class => controller.controller_name}= @provider_account.name
- #obj_actions.button-container
- = link_to 'New Provider Account', new_provider_account_url, :class =>
'button primary', :id => 'new_user_button'
- %div.button-group
- = link_to 'Cancel Editing', provider_account_path(@provider_account),
:class => 'button pill danger', :id => 'new_user_button'
- .corner
+%header.admin-page-header
+ %h1
+ Account:
+ = @provider_account.name
+ #obj_actions
+ Return to:
+ = link_to "Cloud Providers", edit_provider_path(@provider, :view =>
'filter', :details_tab => 'connectivity'), :class =>
'rounded-link'
-%section.content-section.user
+%section.admin-content-section
%header
- %h2
- Edit Provider Account:
- = @provider_account.name
+ %h2.settings Settings
+ .section-controls
+ #obj_actions.button-container
+ .button-group
+ %span.view-toggle
+ = link_to "", provider_provider_account_path(@provider,
@provider_account), :class => "view-toggle pretty", :title =>
"Provider Account Detail"
+ = link_to "", edit_provider_provider_account_path(@provider,
@provider_account), :class => "view-toggle filter active", :title =>
"Edit Provider Account"
.content
- unless @providers.empty?
- = form_for(@provider_account, :url => provider_account_path(@provider_account),
:html => {:multipart => true,:method => :put, :class => 'generic'})
do |f|
+ = form_for([@provider, @provider_account], :html => {:multipart =>
true,:method => :put, :class => 'generic'}) do |f|
= render :partial => "form", :locals => { :form => f }
+ %fieldset.options
+ .button-group
+ = f.submit 'Save Changes', :class => "button pill", :id
=> 'save'
+ = link_to "Delete Account",
provider_provider_account_path(@provider, @provider_account), :method =>
'delete', :confirm => "Are you sure you want to delete?", :class
=> 'button pill danger'
diff --git a/src/app/views/provider_accounts/new.haml
b/src/app/views/provider_accounts/new.haml
index 77b766b..0ce42f8 100644
--- a/src/app/views/provider_accounts/new.haml
+++ b/src/app/views/provider_accounts/new.haml
@@ -3,10 +3,12 @@
%h1 New Provider Account
#obj_actions
Return to:
- = link_to "Cloud Providers", edit_provider_path(@selected_provider, :view
=> 'filter', :details_tab => 'connectivity'), :class =>
'rounded-link'
+ = link_to "Cloud Providers", edit_provider_path(@provider, :view =>
'filter', :details_tab => 'connectivity'), :class =>
'rounded-link'
%section.admin-content-section.provider_accounts
.content
- unless @providers.empty?
- = form_for([@provider, @provider_account], :url => provider_accounts_path, :html
=> {:multipart => true, :class => 'generic'}) do |f|
+ = form_for([@provider, @provider_account], :html => {:multipart => true,
:class => 'generic'}) do |f|
= render :partial => "form", :locals => { :form => f }
+ %fieldset.options
+ = f.submit 'Save', :class => "button pill", :id =>
'save'
diff --git a/src/app/views/provider_accounts/show.haml
b/src/app/views/provider_accounts/show.haml
index 0751c45..0079b43 100644
--- a/src/app/views/provider_accounts/show.haml
+++ b/src/app/views/provider_accounts/show.haml
@@ -1,17 +1,21 @@
= render :partial => 'layouts/admin_nav'
-%header.page-header
- %h1{:class => controller.controller_name}= @account.name
- #obj_actions.button-container
- = link_to 'New Provider Account', new_provider_account_url, :class =>
'button primary', :id => 'new_user_button'
- .button-group
- = link_to 'Edit', edit_provider_account_path(@account), :class =>
'button pill'
- = button_to "Delete", provider_account_path(@account), :method =>
'delete', :confirm => "Are you sure you want to delete?", :class
=> 'button pill danger'
- .corner
+%header.admin-page-header
+ %h1
+ Account:
+ = @provider_account.name
+ #obj_actions
+ Return to:
+ = link_to "Cloud Providers", edit_provider_path(@provider, :view =>
'filter', :details_tab => 'connectivity'), :class =>
'rounded-link'
-%section.content-section.user
+%section.admin-content-section
%header
%h2 Properties
+ .section-controls
+ #obj_actions.button-container
+ .button-group
+ %span.view-toggle
+ = link_to "", provider_provider_account_path(@provider,
@provider_account), :class => "view-toggle pretty active", :title =>
"Provider Account Detail"
+ = link_to "", edit_provider_provider_account_path(@provider,
@provider_account), :class => "view-toggle filter", :title => "Edit
Provider Account"
.content
- %div#view
- = render :partial => 'properties'
+ = render :partial => 'properties'
diff --git a/src/app/views/realms/_list.haml b/src/app/views/realms/_list.haml
index fee0e25..439db54 100644
--- a/src/app/views/realms/_list.haml
+++ b/src/app/views/realms/_list.haml
@@ -8,4 +8,4 @@
%td
- selected = params[:select] == 'all'
= check_box_tag "realm_selected[]", realm.id, selected, :id =>
"realm_checkbox_#{realm.id}"
- %td= link_to realm.name, realm_path(realm)
+ %td= link_to realm.name, provider_realm_path(@provider, realm)
diff --git a/src/app/views/realms/new.haml b/src/app/views/realms/new.haml
index 0a7a394..0de4a0c 100644
--- a/src/app/views/realms/new.haml
+++ b/src/app/views/realms/new.haml
@@ -6,5 +6,5 @@
%h2 Create a new Realm
.content
- = form_for @realm, :url => realms_path, :html => {:class =>
'generic'} do |f|
+ = form_for [@provider, @realm], :url => realms_path, :html => {:class =>
'generic'} do |f|
= render :partial => "form", :locals => { :form => f,
:cancel_path => realms_path }
diff --git a/src/config/routes.rb b/src/config/routes.rb
index e8ed565..a358a39 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -111,7 +111,12 @@ Conductor::Application.routes.draw do
resources :providers do
delete 'multi_destroy', :on => :collection
- resources :provider_accounts
+ resources :provider_accounts do
+ collection do
+ delete 'multi_destroy'
+ get 'set_selected_provider'
+ end
+ end
resources :realms
resources :hardware_profiles
end
@@ -122,13 +127,6 @@ Conductor::Application.routes.draw do
delete 'multi_destroy', :on => :collection
end
- resources :provider_accounts do
- collection do
- delete 'multi_destroy'
- get 'set_selected_provider'
- end
- end
-
resources :roles do
delete 'multi_destroy', :on => :collection
end
diff --git a/src/features/provider_account.feature
b/src/features/provider_account.feature
index 689161a..c04b35b 100644
--- a/src/features/provider_account.feature
+++ b/src/features/provider_account.feature
@@ -7,11 +7,12 @@ Feature: Manage Provider Accounts
Given I am an authorised user
And I am logged in
- Scenario: List provider accounts
+ Scenario: List provider accounts for provider
Given I am on the homepage
And there is a provider named "testprovider"
- When I go to the provider accounts page
- Then I should see "New Provider Account"
+ When I go to the testprovider's edit provider page
+ And I follow "filter_view"
+ Then I should see "New Account"
And there should be no provider accounts
Scenario: List providers in XML format
@@ -30,9 +31,10 @@ Feature: Manage Provider Accounts
Scenario: Create a new Provider Account
Given there is a provider named "testprovider"
And there are no provider accounts
- And I am on the provider accounts page
- When I follow "New Provider Account"
- Then I should be on the new provider account page
+ When I go to the testprovider's edit provider page
+ And I follow "filter_view"
+ And I follow "New Account"
+ Then I should be on the new provider provider account page
And I should see "New Provider Account"
When I select "testprovider" from "provider_account_provider_id"
And I fill in "provider_account[label]" with "testaccount"
--
1.7.6