ACK
On Nov 16, 2010, at 2:12 PM, jprovazn@redhat.com wrote:
From: Jan Provaznik jprovazn@redhat.com
src/app/controllers/cloud_accounts_controller.rb | 12 +- src/app/controllers/provider_controller.rb | 159 -------------------- src/app/controllers/providers_controller.rb | 159 ++++++++++++++++++++ src/app/controllers/templates_controller.rb | 4 +- src/app/helpers/provider_controller_helper.rb | 23 --- src/app/views/dashboard/summary.haml | 2 +- src/app/views/provider/_form.haml | 47 ------ src/app/views/provider/_providers.haml | 13 -- src/app/views/provider/accounts.haml | 125 --------------- src/app/views/provider/delete.haml | 2 - src/app/views/provider/edit.haml | 1 - src/app/views/provider/hardware_profiles.haml | 1 - src/app/views/provider/index.haml | 1 - src/app/views/provider/list.haml | 1 - src/app/views/provider/new.haml | 1 - src/app/views/provider/realms.haml | 1 - src/app/views/provider/settings.haml | 3 - src/app/views/provider/show.haml | 1 - src/app/views/providers/_form.haml | 47 ++++++ src/app/views/providers/_providers.haml | 13 ++ src/app/views/providers/accounts.haml | 125 +++++++++++++++ src/app/views/providers/delete.haml | 2 + src/app/views/providers/edit.haml | 1 + src/app/views/providers/hardware_profiles.haml | 1 + src/app/views/providers/index.haml | 1 + src/app/views/providers/list.haml | 1 + src/app/views/providers/new.haml | 1 + src/app/views/providers/realms.haml | 1 + src/app/views/providers/settings.haml | 3 + src/app/views/providers/show.haml | 1 + src/app/views/settings/index.haml | 2 +- src/config/locales/en.yml | 2 +- src/config/navigation.rb | 6 +- src/features/support/paths.rb | 8 +- .../controllers/cloud_accounts_controller_spec.rb | 4 +- src/spec/controllers/provider_controller_spec.rb | 2 +- 36 files changed, 377 insertions(+), 400 deletions(-) delete mode 100644 src/app/controllers/provider_controller.rb create mode 100644 src/app/controllers/providers_controller.rb delete mode 100644 src/app/helpers/provider_controller_helper.rb delete mode 100644 src/app/views/provider/_form.haml delete mode 100644 src/app/views/provider/_providers.haml delete mode 100644 src/app/views/provider/accounts.haml delete mode 100644 src/app/views/provider/delete.haml delete mode 100644 src/app/views/provider/edit.haml delete mode 100644 src/app/views/provider/hardware_profiles.haml delete mode 100644 src/app/views/provider/index.haml delete mode 100644 src/app/views/provider/list.haml delete mode 100644 src/app/views/provider/new.haml delete mode 100644 src/app/views/provider/realms.haml delete mode 100644 src/app/views/provider/settings.haml delete mode 100644 src/app/views/provider/show.haml create mode 100644 src/app/views/providers/_form.haml create mode 100644 src/app/views/providers/_providers.haml create mode 100644 src/app/views/providers/accounts.haml create mode 100644 src/app/views/providers/delete.haml create mode 100644 src/app/views/providers/edit.haml create mode 100644 src/app/views/providers/hardware_profiles.haml create mode 100644 src/app/views/providers/index.haml create mode 100644 src/app/views/providers/list.haml create mode 100644 src/app/views/providers/new.haml create mode 100644 src/app/views/providers/realms.haml create mode 100644 src/app/views/providers/settings.haml create mode 100644 src/app/views/providers/show.haml
diff --git a/src/app/controllers/cloud_accounts_controller.rb b/src/app/controllers/cloud_accounts_controller.rb index c9a0c67..e1c9b23 100644 --- a/src/app/controllers/cloud_accounts_controller.rb +++ b/src/app/controllers/cloud_accounts_controller.rb @@ -43,7 +43,7 @@ class CloudAccountsController < ApplicationController
if params[:test_account] test_account(@cloud_account)
redirect_to :controller => "provider", :action => "accounts", :id => @provider, :cloud_account => params[:cloud_account]
elsif @cloud_account.valid? quota = Quota.new quota.maximum_running_instances = quota_from_string(params[:quota][:maximum_running_instances])redirect_to :controller => "providers", :action => "accounts", :id => @provider, :cloud_account => params[:cloud_account]
@@ -54,7 +54,7 @@ class CloudAccountsController < ApplicationController if request.post? && @cloud_account.save && @cloud_account.populate_realms flash[:notice] = "Provider account added." end
redirect_to :controller => "provider", :action => "accounts", :id => @provider
else if not @cloud_account.valid_credentials?redirect_to :controller => "providers", :action => "accounts", :id => @provider kick_condor
@@ -64,7 +64,7 @@ class CloudAccountsController < ApplicationController else flash[:notice] = "You must fill in all the required fields" end
redirect_to :controller => "provider", :action => "accounts", :id => @provider, :cloud_account => params[:cloud_account]
end endredirect_to :controller => "providers", :action => "accounts", :id => @provider, :cloud_account => params[:cloud_account]
@@ -111,7 +111,7 @@ class CloudAccountsController < ApplicationController end if success flash[:notice] = "Account updated."
redirect_to :controller => 'provider', :action => 'accounts', :id => @provider
else flash.now[:notice] = "Error updating the cloud account." render :template => 'provider/accounts'redirect_to :controller => 'providers', :action => 'accounts', :id => @provider
@@ -123,7 +123,7 @@ class CloudAccountsController < ApplicationController require_privilege(Privilege::ACCOUNT_MODIFY,@cloud_account.provider) if @cloud_account.update_attributes(params[:cloud_account]) flash[:notice] = "Cloud Account updated!"
redirect_to :controller => 'provider', :action => 'accounts', :id => @cloud_account.provider.id
else render :action => :edit endredirect_to :controller => 'providers', :action => 'accounts', :id => @cloud_account.provider.id
@@ -147,7 +147,7 @@ class CloudAccountsController < ApplicationController else flash[:notice] = "Cloud Account could not be destroyed" end
- redirect_to :controller => 'provider', :action => 'accounts', :id => provider.id
redirect_to :controller => 'providers', :action => 'accounts', :id => provider.id end
def test_account(account)
diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb deleted file mode 100644 index da5c9bb..0000000 --- a/src/app/controllers/provider_controller.rb +++ /dev/null @@ -1,159 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html.
-# Filters added to this controller apply to all controllers in the application. -# Likewise, all the methods added will be available for all controllers.
-class ProviderController < ApplicationController
- before_filter :require_user
- before_filter :load_providers, :only => [:index, :show, :accounts, :list]
- def section_id
- 'administration'
- end
- def index
- end
- def show
- @provider = Provider.find(:first, :conditions => {:id => params[:id]})
- require_privilege(Privilege::PROVIDER_VIEW, @provider)
- end
- def edit
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.find(:first, :conditions => {:id => params[:id]})
- require_privilege(Privilege::PROVIDER_MODIFY, @provider)
- render :show
- end
- def new
- require_privilege(Privilege::PROVIDER_MODIFY)
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.new(params[:provider])
- kick_condor
- render :show
- end
- def create
- require_privilege(Privilege::PROVIDER_MODIFY)
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.new(params[:provider])
- if params[:test_connection]
test_connection(@provider)
render :action => "new"
- else
@provider.set_cloud_type!
if @provider.save && @provider.populate_hardware_profiles
flash[:notice] = "Provider added."
redirect_to :action => "show", :id => @provider
else
flash[:notice] = "Cannot add the provider."
render :action => "new"
end
kick_condor
- end
- end
- def update
- require_privilege(Privilege::PROVIDER_MODIFY)
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.find(:first, :conditions => {:id => params[:provider][:id]})
- previous_cloud_type = @provider.cloud_type
- @provider.update_attributes(params[:provider])
- if params[:test_connection]
test_connection(@provider)
render :action => "edit"
- else
@provider.set_cloud_type!
if previous_cloud_type != @provider.cloud_type
@provider.errors.add :url, "points to a different provider"
end
if @provider.errors.empty? and @provider.save
flash[:notice] = "Provider updated."
redirect_to :action => "show", :id => @provider
else
flash[:notice] = "Cannot update the provider."
render :action => "edit"
end
kick_condor
- end
- end
- def destroy
- if request.post?
@provider = Provider.find(params[:provider][:id])
require_privilege(Privilege::PROVIDER_MODIFY, p)
if @provider.destroy and @provider.destroyed?
redirect_to :action => "index"
else
flash[:error] = {
:summary => "Failed to delete Provider",
:failures => @provider.errors.full_messages,
}
render :action => 'show'
end
- end
- end
- def hardware_profiles
- @provider = Provider.find(params[:id])
- @hardware_profiles = @provider.hardware_profiles
- require_privilege(Privilege::PROVIDER_VIEW, @provider)
- end
- def accounts
- @provider = Provider.find(:first, :conditions => {:id => params[:id]})
- require_privilege(Privilege::ACCOUNT_VIEW, @provider)
- if params[:cloud_account]
@cloud_account = CloudAccount.new(params[:cloud_account])
@quota = Quota.new(params[:quota])
- end
- end
- def realms
- @provider = Provider.find(params[:id])
- @realm_names = @provider.realms.collect { |r| r.name }
- require_privilege(Privilege::PROVIDER_VIEW, @provider)
- end
- def settings
- @provider = Provider.find(params[:id])
- end
- def list
- end
- def test_connection(provider)
- @provider.errors.clear
- if @provider.connect
flash[:notice] = "Successfuly Connected to Provider"
- else
flash[:notice] = "Failed to Connect to Provider"
@provider.errors.add :url
- end
- end
- protected
- def load_providers
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_VIEW)
- end
-end diff --git a/src/app/controllers/providers_controller.rb b/src/app/controllers/providers_controller.rb new file mode 100644 index 0000000..5ea4aee --- /dev/null +++ b/src/app/controllers/providers_controller.rb @@ -0,0 +1,159 @@ +# +# Copyright (C) 2009 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. A copy of the GNU General Public License is +# also available at http://www.gnu.org/copyleft/gpl.html.
+# Filters added to this controller apply to all controllers in the application. +# Likewise, all the methods added will be available for all controllers.
+class ProvidersController < ApplicationController
- before_filter :require_user
- before_filter :load_providers, :only => [:index, :show, :accounts, :list]
- def section_id
- 'administration'
- end
- def index
- end
- def show
- @provider = Provider.find(:first, :conditions => {:id => params[:id]})
- require_privilege(Privilege::PROVIDER_VIEW, @provider)
- end
- def edit
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.find(:first, :conditions => {:id => params[:id]})
- require_privilege(Privilege::PROVIDER_MODIFY, @provider)
- render :show
- end
- def new
- require_privilege(Privilege::PROVIDER_MODIFY)
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.new(params[:provider])
- kick_condor
- render :show
- end
- def create
- require_privilege(Privilege::PROVIDER_MODIFY)
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.new(params[:provider])
- if params[:test_connection]
test_connection(@provider)
render :action => "new"
- else
@provider.set_cloud_type!
if @provider.save && @provider.populate_hardware_profiles
flash[:notice] = "Provider added."
redirect_to :action => "show", :id => @provider
else
flash[:notice] = "Cannot add the provider."
render :action => "new"
end
kick_condor
- end
- end
- def update
- require_privilege(Privilege::PROVIDER_MODIFY)
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
- @provider = Provider.find(:first, :conditions => {:id => params[:provider][:id]})
- previous_cloud_type = @provider.cloud_type
- @provider.update_attributes(params[:provider])
- if params[:test_connection]
test_connection(@provider)
render :action => "edit"
- else
@provider.set_cloud_type!
if previous_cloud_type != @provider.cloud_type
@provider.errors.add :url, "points to a different provider"
end
if @provider.errors.empty? and @provider.save
flash[:notice] = "Provider updated."
redirect_to :action => "show", :id => @provider
else
flash[:notice] = "Cannot update the provider."
render :action => "edit"
end
kick_condor
- end
- end
- def destroy
- if request.post?
@provider = Provider.find(params[:provider][:id])
require_privilege(Privilege::PROVIDER_MODIFY, p)
if @provider.destroy and @provider.destroyed?
redirect_to :action => "index"
else
flash[:error] = {
:summary => "Failed to delete Provider",
:failures => @provider.errors.full_messages,
}
render :action => 'show'
end
- end
- end
- def hardware_profiles
- @provider = Provider.find(params[:id])
- @hardware_profiles = @provider.hardware_profiles
- require_privilege(Privilege::PROVIDER_VIEW, @provider)
- end
- def accounts
- @provider = Provider.find(:first, :conditions => {:id => params[:id]})
- require_privilege(Privilege::ACCOUNT_VIEW, @provider)
- if params[:cloud_account]
@cloud_account = CloudAccount.new(params[:cloud_account])
@quota = Quota.new(params[:quota])
- end
- end
- def realms
- @provider = Provider.find(params[:id])
- @realm_names = @provider.realms.collect { |r| r.name }
- require_privilege(Privilege::PROVIDER_VIEW, @provider)
- end
- def settings
- @provider = Provider.find(params[:id])
- end
- def list
- end
- def test_connection(provider)
- @provider.errors.clear
- if @provider.connect
flash[:notice] = "Successfuly Connected to Provider"
- else
flash[:notice] = "Failed to Connect to Provider"
@provider.errors.add :url
- end
- end
- protected
- def load_providers
- @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_VIEW)
- end
+end diff --git a/src/app/controllers/templates_controller.rb b/src/app/controllers/templates_controller.rb index 55e41c9..12df295 100644 --- a/src/app/controllers/templates_controller.rb +++ b/src/app/controllers/templates_controller.rb @@ -194,12 +194,12 @@ class TemplatesController < ApplicationController # account exists unless provider = Provider.find_by_cloud_type(target) flash_error("There is no provider of '#{target}' type, you can add provider \ -on <a href="#{url_for :controller => 'provider'}">the providers page.</a>") +on <a href="#{url_for :controller => 'providers'}">the providers page.</a>") render :action => 'build_form' and return end if provider.cloud_accounts.empty? flash_error("There is no provider account for '#{target}' provider, you can \ -add account on <a href="#{url_for :controller => 'provider', \ +add account on <a href="#{url_for :controller => 'providers', \ :action => 'accounts', :id => provider.id}">the provider accounts page</a>") render :action => 'build_form' and return end diff --git a/src/app/helpers/provider_controller_helper.rb b/src/app/helpers/provider_controller_helper.rb deleted file mode 100644 index 46378ed..0000000 --- a/src/app/helpers/provider_controller_helper.rb +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html.
-# Filters added to this controller apply to all controllers in the application. -# Likewise, all the methods added will be available for all controllers.
-module ProviderControllerHelper -end diff --git a/src/app/views/dashboard/summary.haml b/src/app/views/dashboard/summary.haml index 5eb49a5..e6ba2dd 100644 --- a/src/app/views/dashboard/summary.haml +++ b/src/app/views/dashboard/summary.haml @@ -31,7 +31,7 @@ %h2 Actions - if @is_admin
%a{:href => url_for(:controller => "provider", :action => "new")}
%a{:href => url_for(:controller => "providers", :action => "new")} Add a Provider %a{:href => url_for(:controller => "users", :action => "new")} Create a User
diff --git a/src/app/views/provider/_form.haml b/src/app/views/provider/_form.haml deleted file mode 100644 index 14cd292..0000000 --- a/src/app/views/provider/_form.haml +++ /dev/null @@ -1,47 +0,0 @@ -- readonly = controller.action_name == 'show' ? true : false -- new_provider = ['new', 'create'].include? controller.action_name -- edit_provider = ['edit', 'update'].include? controller.action_name -= render :partial => 'providers' -#details.grid_13
- %nav.subsubnav
- = render_navigation(:level => 4)
- if new_provider
- form_action = 'create'
- elsif edit_provider
- form_action = 'update'
- form_for @provider, :url => {:controller => :provider, :action => form_action}, :class => "dcloud_form" do |f|
- %fieldset
%label.grid_4.alpha.big{ :for => "provider_name" }
= t('.provider_name')
- unless readonly
%span.required
*
%label.grid_5.big{ :for => "provider_url" }
= t('.provider_url')
- unless readonly
%span.required
*
%div.grid_4.omega
= f.error_message_on :url, 'URL '
= f.error_message_on :name, 'Name '
= f.text_field :name, :title => t('.provider_name'), :value => (@provider.name if @provider), :disabled => ('disabled' if readonly), :class => "clear grid_4 alpha"
= f.text_field :url, :title => t('.provider_url'), :class => 'emailinput', :value => (@provider.url if @provider), :disabled => ('disabled' if readonly), :class => "grid_5"
- if edit_provider:
= f.hidden_field :id, :value => @provider.id
.clear.prefix_4.grid_5.suffix_4.alpha.omega
- if new_provider or edit_provider
%span
(
%button.linkbutton.nospace{ :type => 'submit', :value => t('.test_connection'), :name => 'test_connection', :id => 'test_connection' }<>
= t('.test_connection')
)
- unless readonly
%p.requirement
%span.required
*
\-
= t('.required_field')
- if edit_provider
%input{ :type => 'submit', :value => t(:save), :name => 'save_provider', :id => 'save_provider' }
- elsif new_provider
%input{ :type => 'submit', :value => t(:add), :name => 'add_provider', :id => 'add_provider' }
diff --git a/src/app/views/provider/_providers.haml b/src/app/views/provider/_providers.haml deleted file mode 100644 index f051692..0000000 --- a/src/app/views/provider/_providers.haml +++ /dev/null @@ -1,13 +0,0 @@ -#providers_nav.grid_3.actionsidebar
- %dl
- %dt
= t('provider.providers')
- @providers.each do |provider|
%dd
- selected = 'selected' if @provider and (provider.id == @provider.id)
%a{ :href => url_for(:controller => 'provider', :action => 'show', :id => provider), :class => selected }
= provider.name
- form_tag({:controller => 'provider', :action => 'edit', :id => @provider}, {:method => :post , :class => 'buttononly'}) do
- = submit_tag t(:edit), :disabled => ('disabled' unless @provider and ['show', 'accounts'].include? controller.action_name)
- form_tag({:controller => 'provider', :action => 'new'}, {:method => :get , :class => 'buttononly'}) do
- %input{ :type => 'submit', :value => t(:add), :disabled => ('disabled' unless @providers.length == 0) }
diff --git a/src/app/views/provider/accounts.haml b/src/app/views/provider/accounts.haml deleted file mode 100644 index e555717..0000000 --- a/src/app/views/provider/accounts.haml +++ /dev/null @@ -1,125 +0,0 @@ -:javascript
- function set_unlimited_quota(elem_id) {
- $("#" + elem_id)[0].value = "unlimited";
- }
-= render :partial => 'provider/providers' -#details.grid_13
- %nav.subsubnav
- = render_navigation(:level => 4)
- %h1
- = t('.provider_accounts')
- form_tag ({:controller => 'cloud_accounts', :action => 'update_accounts'}), :multipart => true do
- = hidden_field :provider, :id, :value => @provider.id
- @provider.cloud_accounts.each do |acct|
%fieldset.clearfix.nomargin
%label.grid_4.la.alpha
= t('.account_name')
%span.required *
%label.grid_3.la
= t('.user_name')
%span.required *
%label.grid_3.la
= t('.password')
%span.required *
%label.grid_3.la.omega
= t('.quota_instances')
%span.required *
%fieldset.nomargin.clearfix
- disabled = 'disabled' unless has_account_modify?(@provider)
- cloud_account_id = "cloud_accounts[#{acct.id}]"
= text_field cloud_account_id, :label, :title => t('.account_name'), :value => acct.label, :disabled => disabled, :class => "grid_4 alpha"
= text_field cloud_account_id, :username, :title => t('.user_name'), :value => acct.username, :disabled => disabled, :class => "grid_3"
= password_field cloud_account_id, :password, :title => t('.password'), :disabled => disabled, :class => "grid_3"
= error_message_on :maximum_running_instances, 'Maximum Running Instances '
= text_field "quota[#{acct.id}]", :maximum_running_instances, :title => t('.quota_instances'), :value => (acct.quota.maximum_running_instances.nil? ? "unlimited" : acct.quota.maximum_running_instances), :disabled => disabled, :id => "quota_instances#{acct.id}", :class => "grid_3 omega"
%fieldset.nomargin.clearfix
.grid_3.prefix_10.alpha.omega
(
%button.linkbutton.nospace{ :type => 'button', :onclick => "set_unlimited_quota(\"quota_instances#{acct.id}\");" }<>
= t('.unlimited_quota')
)
%fieldset.clearfix.nomargin
%label.grid_4.la.alpha
= t('.account_number')
%span.required *
%label.grid_3.la
= t('.account_private_cert')
%span.required *
%label.grid_3.la
= t('.account_public_cert')
%span.required *
.grid_3.omega
%fieldset.clearfix
= text_field cloud_account_id, :account_number, :title => t('.account_number'), :value => acct.account_number, :disabled => disabled, :class => "grid_4 alpha"
.grid_3
= file_field cloud_account_id, :x509_cert_priv_file, :title => t('.account_private_cert'), :disabled => disabled
.grid_3
= file_field cloud_account_id, :x509_cert_pub_file, :title => t('.account_public_cert'), :disabled => disabled
- remove_path = url_for :controller => 'cloud_accounts', :action => 'destroy', :id => acct.id if has_account_modify?(@provider) && acct.destroyable?
.grid_3.omega
%a.button{ :href => remove_path, :name => "remove_acc_#{acct.id}", :class => "tiny #{'disabled' unless remove_path}" }
= t(:remove)
%fieldset.clearfix.gap
= link_to t(:reset), {:controller => 'provider', :action => 'accounts', :id => @provider.id}, :class => "button dialogbutton" unless @provider.cloud_accounts.empty?
= submit_tag t(:save), :name => 'update_cloud_accounts', :class => "dialogbutton" unless @provider.cloud_accounts.empty?
- %h2
- = t('.new_provider_account')
- form_tag({:controller => 'cloud_accounts', :action => 'create'}, :multipart => true) do
- = hidden_field :cloud_account, :provider_id, :value => @provider.id
- %fieldset.clearfix.nomargin
%label.grid_4.la.alpha
= t('.account_name')
%span.required *
%label.grid_3.la
= t('.user_name')
%span.required *
%label.grid_3.la
= t('.password')
%span.required *
%label.grid_3.la.omega
= t('.quota_instances')
%span.required *
- %fieldset.nomargin.clearfix
= text_field :cloud_account, :label, :title => t('.account_name'), :class => "grid_4 alpha"
= text_field :cloud_account, :username, :title => t('.user_name'), :class => "grid_3"
= password_field :cloud_account, :password, :title => t('.password'), :class => "grid_3"
= text_field "quota", :maximum_running_instances, :title => t('.quota_instances'), :value => "unlimited",:id => "quota_instances", :class => "grid_3 omega"
- %fieldset.nomargin.clearfix
.grid_3.prefix_10.alpha.omega
(
%button.linkbutton.nospace{ :type => 'button', :onclick => "set_unlimited_quota(\"quota_instances\");" }<>
= t('.unlimited_quota')
)
- %fieldset.clearfix.nomargin
%label.grid_4.la.alpha
= t('.account_number')
%span.required *
%label.grid_3.la
= t('.account_private_cert')
%span.required *
%label.grid_3.la
= t('.account_public_cert')
%span.required *
.grid_3.omega
- %fieldset.clearfix.nomargin
= text_field :cloud_account, :account_number, :title => t('.account_number'), :class => "grid_4 alpha"
.grid_3
= file_field :cloud_account, :x509_cert_priv_file, :title => t('.account_private_cert')
.grid_3
= file_field :cloud_account, :x509_cert_pub_file, :title => t('.account_public_cert')
- remove_path = url_for :controller => 'cloud_accounts', :action => 'destroy'
.grid_3.omega
(
%button.linkbutton.nospace{ :type => 'submit', :value => t('.test_account'), :name => 'test_account', :id => 'test_account' }<>
= t('.test_account')
)
- %fieldset.clearfix
.grid_13.alpha.omega
= submit_tag t(:add), :class => "ra nomargin dialogbutton"
- %section
%p.requirement
%span.required *
\-
= t('.required_field')
diff --git a/src/app/views/provider/delete.haml b/src/app/views/provider/delete.haml deleted file mode 100644 index 6727d77..0000000 --- a/src/app/views/provider/delete.haml +++ /dev/null @@ -1,2 +0,0 @@ -%h1 ProviderController#delete -%p Find me in app/views/provider_controller/delete.html.erb diff --git a/src/app/views/provider/edit.haml b/src/app/views/provider/edit.haml deleted file mode 100644 index c66fabf..0000000 --- a/src/app/views/provider/edit.haml +++ /dev/null @@ -1 +0,0 @@ -= render :partial => 'form' diff --git a/src/app/views/provider/hardware_profiles.haml b/src/app/views/provider/hardware_profiles.haml deleted file mode 100644 index 96fe378..0000000 --- a/src/app/views/provider/hardware_profiles.haml +++ /dev/null @@ -1 +0,0 @@ -= render :partial => 'hardware_profiles/list' diff --git a/src/app/views/provider/index.haml b/src/app/views/provider/index.haml deleted file mode 100644 index 9823f42..0000000 --- a/src/app/views/provider/index.haml +++ /dev/null @@ -1 +0,0 @@ -= render :partial => 'providers' diff --git a/src/app/views/provider/list.haml b/src/app/views/provider/list.haml deleted file mode 100644 index 6e68450..0000000 --- a/src/app/views/provider/list.haml +++ /dev/null @@ -1 +0,0 @@ -= render :partial => 'provider/providers' \ No newline at end of file diff --git a/src/app/views/provider/new.haml b/src/app/views/provider/new.haml deleted file mode 100644 index c66fabf..0000000 --- a/src/app/views/provider/new.haml +++ /dev/null @@ -1 +0,0 @@ -= render :partial => 'form' diff --git a/src/app/views/provider/realms.haml b/src/app/views/provider/realms.haml deleted file mode 100644 index 31f7886..0000000 --- a/src/app/views/provider/realms.haml +++ /dev/null @@ -1 +0,0 @@ -= render :partial => 'realms/list' diff --git a/src/app/views/provider/settings.haml b/src/app/views/provider/settings.haml deleted file mode 100644 index b4cdc43..0000000 --- a/src/app/views/provider/settings.haml +++ /dev/null @@ -1,3 +0,0 @@ -- form_tag({ :action => 'destroy' }, {:onsubmit => "return confirm('Really delete the provider?');"}) do
- = hidden_field :provider, :id
- = submit_tag "Delete Provider", :class => "submit_link"
diff --git a/src/app/views/provider/show.haml b/src/app/views/provider/show.haml deleted file mode 100644 index c66fabf..0000000 --- a/src/app/views/provider/show.haml +++ /dev/null @@ -1 +0,0 @@ -= render :partial => 'form' diff --git a/src/app/views/providers/_form.haml b/src/app/views/providers/_form.haml new file mode 100644 index 0000000..94e2ebf --- /dev/null +++ b/src/app/views/providers/_form.haml @@ -0,0 +1,47 @@ +- readonly = controller.action_name == 'show' ? true : false +- new_provider = ['new', 'create'].include? controller.action_name +- edit_provider = ['edit', 'update'].include? controller.action_name += render :partial => 'providers' +#details.grid_13
- %nav.subsubnav
- = render_navigation(:level => 4)
- if new_provider
- form_action = 'create'
- elsif edit_provider
- form_action = 'update'
- form_for @provider, :url => {:controller => :providers, :action => form_action}, :class => "dcloud_form" do |f|
- %fieldset
%label.grid_4.alpha.big{ :for => "provider_name" }
= t('.provider_name')
- unless readonly
%span.required
*
%label.grid_5.big{ :for => "provider_url" }
= t('.provider_url')
- unless readonly
%span.required
*
%div.grid_4.omega
= f.error_message_on :url, 'URL '
= f.error_message_on :name, 'Name '
= f.text_field :name, :title => t('.provider_name'), :value => (@provider.name if @provider), :disabled => ('disabled' if readonly), :class => "clear grid_4 alpha"
= f.text_field :url, :title => t('.provider_url'), :class => 'emailinput', :value => (@provider.url if @provider), :disabled => ('disabled' if readonly), :class => "grid_5"
- if edit_provider:
= f.hidden_field :id, :value => @provider.id
.clear.prefix_4.grid_5.suffix_4.alpha.omega
- if new_provider or edit_provider
%span
(
%button.linkbutton.nospace{ :type => 'submit', :value => t('.test_connection'), :name => 'test_connection', :id => 'test_connection' }<>
= t('.test_connection')
)
- unless readonly
%p.requirement
%span.required
*
\-
= t('.required_field')
- if edit_provider
%input{ :type => 'submit', :value => t(:save), :name => 'save_provider', :id => 'save_provider' }
- elsif new_provider
%input{ :type => 'submit', :value => t(:add), :name => 'add_provider', :id => 'add_provider' }
diff --git a/src/app/views/providers/_providers.haml b/src/app/views/providers/_providers.haml new file mode 100644 index 0000000..b1a9bec --- /dev/null +++ b/src/app/views/providers/_providers.haml @@ -0,0 +1,13 @@ +#providers_nav.grid_3.actionsidebar
- %dl
- %dt
= t('providers.providers')
- @providers.each do |provider|
%dd
- selected = 'selected' if @provider and (provider.id == @provider.id)
%a{ :href => url_for(:controller => 'providers', :action => 'show', :id => provider), :class => selected }
= provider.name
- form_tag({:controller => 'providers', :action => 'edit', :id => @provider}, {:method => :post , :class => 'buttononly'}) do
- = submit_tag t(:edit), :disabled => ('disabled' unless @provider and ['show', 'accounts'].include? controller.action_name)
- form_tag({:controller => 'providers', :action => 'new'}, {:method => :get , :class => 'buttononly'}) do
- %input{ :type => 'submit', :value => t(:add), :disabled => ('disabled' unless @providers.length == 0) }
diff --git a/src/app/views/providers/accounts.haml b/src/app/views/providers/accounts.haml new file mode 100644 index 0000000..f6f9c84 --- /dev/null +++ b/src/app/views/providers/accounts.haml @@ -0,0 +1,125 @@ +:javascript
- function set_unlimited_quota(elem_id) {
- $("#" + elem_id)[0].value = "unlimited";
- }
+= render :partial => 'providers/providers' +#details.grid_13
- %nav.subsubnav
- = render_navigation(:level => 4)
- %h1
- = t('.provider_accounts')
- form_tag ({:controller => 'cloud_accounts', :action => 'update_accounts'}), :multipart => true do
- = hidden_field :provider, :id, :value => @provider.id
- @provider.cloud_accounts.each do |acct|
%fieldset.clearfix.nomargin
%label.grid_4.la.alpha
= t('.account_name')
%span.required *
%label.grid_3.la
= t('.user_name')
%span.required *
%label.grid_3.la
= t('.password')
%span.required *
%label.grid_3.la.omega
= t('.quota_instances')
%span.required *
%fieldset.nomargin.clearfix
- disabled = 'disabled' unless has_account_modify?(@provider)
- cloud_account_id = "cloud_accounts[#{acct.id}]"
= text_field cloud_account_id, :label, :title => t('.account_name'), :value => acct.label, :disabled => disabled, :class => "grid_4 alpha"
= text_field cloud_account_id, :username, :title => t('.user_name'), :value => acct.username, :disabled => disabled, :class => "grid_3"
= password_field cloud_account_id, :password, :title => t('.password'), :disabled => disabled, :class => "grid_3"
= error_message_on :maximum_running_instances, 'Maximum Running Instances '
= text_field "quota[#{acct.id}]", :maximum_running_instances, :title => t('.quota_instances'), :value => (acct.quota.maximum_running_instances.nil? ? "unlimited" : acct.quota.maximum_running_instances), :disabled => disabled, :id => "quota_instances#{acct.id}", :class => "grid_3 omega"
%fieldset.nomargin.clearfix
.grid_3.prefix_10.alpha.omega
(
%button.linkbutton.nospace{ :type => 'button', :onclick => "set_unlimited_quota(\"quota_instances#{acct.id}\");" }<>
= t('.unlimited_quota')
)
%fieldset.clearfix.nomargin
%label.grid_4.la.alpha
= t('.account_number')
%span.required *
%label.grid_3.la
= t('.account_private_cert')
%span.required *
%label.grid_3.la
= t('.account_public_cert')
%span.required *
.grid_3.omega
%fieldset.clearfix
= text_field cloud_account_id, :account_number, :title => t('.account_number'), :value => acct.account_number, :disabled => disabled, :class => "grid_4 alpha"
.grid_3
= file_field cloud_account_id, :x509_cert_priv_file, :title => t('.account_private_cert'), :disabled => disabled
.grid_3
= file_field cloud_account_id, :x509_cert_pub_file, :title => t('.account_public_cert'), :disabled => disabled
- remove_path = url_for :controller => 'cloud_accounts', :action => 'destroy', :id => acct.id if has_account_modify?(@provider) && acct.destroyable?
.grid_3.omega
%a.button{ :href => remove_path, :name => "remove_acc_#{acct.id}", :class => "tiny #{'disabled' unless remove_path}" }
= t(:remove)
%fieldset.clearfix.gap
= link_to t(:reset), {:controller => 'provider', :action => 'accounts', :id => @provider.id}, :class => "button dialogbutton" unless @provider.cloud_accounts.empty?
= submit_tag t(:save), :name => 'update_cloud_accounts', :class => "dialogbutton" unless @provider.cloud_accounts.empty?
- %h2
- = t('.new_provider_account')
- form_tag({:controller => 'cloud_accounts', :action => 'create'}, :multipart => true) do
- = hidden_field :cloud_account, :provider_id, :value => @provider.id
- %fieldset.clearfix.nomargin
%label.grid_4.la.alpha
= t('.account_name')
%span.required *
%label.grid_3.la
= t('.user_name')
%span.required *
%label.grid_3.la
= t('.password')
%span.required *
%label.grid_3.la.omega
= t('.quota_instances')
%span.required *
- %fieldset.nomargin.clearfix
= text_field :cloud_account, :label, :title => t('.account_name'), :class => "grid_4 alpha"
= text_field :cloud_account, :username, :title => t('.user_name'), :class => "grid_3"
= password_field :cloud_account, :password, :title => t('.password'), :class => "grid_3"
= text_field "quota", :maximum_running_instances, :title => t('.quota_instances'), :value => "unlimited",:id => "quota_instances", :class => "grid_3 omega"
- %fieldset.nomargin.clearfix
.grid_3.prefix_10.alpha.omega
(
%button.linkbutton.nospace{ :type => 'button', :onclick => "set_unlimited_quota(\"quota_instances\");" }<>
= t('.unlimited_quota')
)
- %fieldset.clearfix.nomargin
%label.grid_4.la.alpha
= t('.account_number')
%span.required *
%label.grid_3.la
= t('.account_private_cert')
%span.required *
%label.grid_3.la
= t('.account_public_cert')
%span.required *
.grid_3.omega
- %fieldset.clearfix.nomargin
= text_field :cloud_account, :account_number, :title => t('.account_number'), :class => "grid_4 alpha"
.grid_3
= file_field :cloud_account, :x509_cert_priv_file, :title => t('.account_private_cert')
.grid_3
= file_field :cloud_account, :x509_cert_pub_file, :title => t('.account_public_cert')
- remove_path = url_for :controller => 'cloud_accounts', :action => 'destroy'
.grid_3.omega
(
%button.linkbutton.nospace{ :type => 'submit', :value => t('.test_account'), :name => 'test_account', :id => 'test_account' }<>
= t('.test_account')
)
- %fieldset.clearfix
.grid_13.alpha.omega
= submit_tag t(:add), :class => "ra nomargin dialogbutton"
- %section
%p.requirement
%span.required *
\-
= t('.required_field')
diff --git a/src/app/views/providers/delete.haml b/src/app/views/providers/delete.haml new file mode 100644 index 0000000..6727d77 --- /dev/null +++ b/src/app/views/providers/delete.haml @@ -0,0 +1,2 @@ +%h1 ProviderController#delete +%p Find me in app/views/provider_controller/delete.html.erb diff --git a/src/app/views/providers/edit.haml b/src/app/views/providers/edit.haml new file mode 100644 index 0000000..c66fabf --- /dev/null +++ b/src/app/views/providers/edit.haml @@ -0,0 +1 @@ += render :partial => 'form' diff --git a/src/app/views/providers/hardware_profiles.haml b/src/app/views/providers/hardware_profiles.haml new file mode 100644 index 0000000..96fe378 --- /dev/null +++ b/src/app/views/providers/hardware_profiles.haml @@ -0,0 +1 @@ += render :partial => 'hardware_profiles/list' diff --git a/src/app/views/providers/index.haml b/src/app/views/providers/index.haml new file mode 100644 index 0000000..9823f42 --- /dev/null +++ b/src/app/views/providers/index.haml @@ -0,0 +1 @@ += render :partial => 'providers' diff --git a/src/app/views/providers/list.haml b/src/app/views/providers/list.haml new file mode 100644 index 0000000..9517a21 --- /dev/null +++ b/src/app/views/providers/list.haml @@ -0,0 +1 @@ += render :partial => 'providers/providers' diff --git a/src/app/views/providers/new.haml b/src/app/views/providers/new.haml new file mode 100644 index 0000000..c66fabf --- /dev/null +++ b/src/app/views/providers/new.haml @@ -0,0 +1 @@ += render :partial => 'form' diff --git a/src/app/views/providers/realms.haml b/src/app/views/providers/realms.haml new file mode 100644 index 0000000..31f7886 --- /dev/null +++ b/src/app/views/providers/realms.haml @@ -0,0 +1 @@ += render :partial => 'realms/list' diff --git a/src/app/views/providers/settings.haml b/src/app/views/providers/settings.haml new file mode 100644 index 0000000..b4cdc43 --- /dev/null +++ b/src/app/views/providers/settings.haml @@ -0,0 +1,3 @@ +- form_tag({ :action => 'destroy' }, {:onsubmit => "return confirm('Really delete the provider?');"}) do
- = hidden_field :provider, :id
- = submit_tag "Delete Provider", :class => "submit_link"
diff --git a/src/app/views/providers/show.haml b/src/app/views/providers/show.haml new file mode 100644 index 0000000..c66fabf --- /dev/null +++ b/src/app/views/providers/show.haml @@ -0,0 +1 @@ += render :partial => 'form' diff --git a/src/app/views/settings/index.haml b/src/app/views/settings/index.haml index 80f0bd6..5963ec4 100644 --- a/src/app/views/settings/index.haml +++ b/src/app/views/settings/index.haml @@ -5,7 +5,7 @@ = t('.manage_providers') %p = t('.manage_providers_desc')
- = link_to t(:continue), {:controller => 'provider'}, :class => 'button'
- = link_to t(:continue), {:controller => 'providers'}, :class => 'button' %li#users.grid_8 = image_tag "blnk.png", :class => "icon", :alt => "" %h2
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml index 0d8cc39..6539cbd 100644 --- a/src/config/locales/en.yml +++ b/src/config/locales/en.yml @@ -87,7 +87,7 @@ en: self_service_default: 'User Treatment: Self-service default' quota: Quota account: Account
- provider:
- providers: providers: PROVIDERS form: provider_name: Provider Name
diff --git a/src/config/navigation.rb b/src/config/navigation.rb index c29b9c9..caa864b 100644 --- a/src/config/navigation.rb +++ b/src/config/navigation.rb @@ -7,9 +7,9 @@ SimpleNavigation::Configuration.run do |navigation| end first_level.item :administration, t(:administration), '#', :class => 'administration' do |second_level| second_level.item :system_settings, t(:system_settings), :controller => 'settings' do |third_level|
third_level.item :manage_providers, t(:manage_providers), :controller => 'provider' do |fourth_level|
fourth_level.item :provider_summary, t(:provider_summary), { :controller => 'provider', :action => 'show', :id => (@provider.id if @provider) }, :highlights_on => /\/provider\/(show|edit)/
fourth_level.item :provider_accounts, t(:provider_accounts), { :controller => 'provider', :action => 'accounts', :id => (@provider.id if @provider) }, :highlights_on => /\/provider\/accounts/
third_level.item :manage_providers, t(:manage_providers), :controller => 'providers' do |fourth_level|
fourth_level.item :provider_summary, t(:provider_summary), { :controller => 'providers', :action => 'show', :id => (@provider.id if @provider) }, :highlights_on => /\/providers\/(show|edit)/
fourth_level.item :provider_accounts, t(:provider_accounts), { :controller => 'providers', :action => 'accounts', :id => (@provider.id if @provider) }, :highlights_on => /\/providers\/accounts/ fourth_level.item :scheduling_policies, t(:scheduling_policies), '#' fourth_level.item :services_provided, t(:services_provided), '#' fourth_level.item :map_profiles, t(:map_profiles), '#'
diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb index 198099b..e948161 100644 --- a/src/features/support/paths.rb +++ b/src/features/support/paths.rb @@ -27,16 +27,16 @@ module NavigationHelpers user_session_path
when /the providers page/
url_for :controller => 'provider', :action => 'index', :only_path => true
url_for :controller => 'providers', :action => 'index', :only_path => true
when /the new provider page/
url_for :controller => 'provider', :action => 'new', :only_path => true
url_for :controller => 'providers', :action => 'new', :only_path => true
when /the show provider page/
url_for :controller => 'provider', :action => 'show', :only_path => true
url_for :controller => 'providers', :action => 'show', :only_path => true
when /the provider settings page/
url_for :controller => 'provider', :action => 'settings', :only_path => true
url_for :controller => 'providers', :action => 'settings', :only_path => true
when /the settings page/ settings_path
diff --git a/src/spec/controllers/cloud_accounts_controller_spec.rb b/src/spec/controllers/cloud_accounts_controller_spec.rb index 7a82a7a..f3b866a 100644 --- a/src/spec/controllers/cloud_accounts_controller_spec.rb +++ b/src/spec/controllers/cloud_accounts_controller_spec.rb @@ -29,7 +29,7 @@ describe CloudAccountsController do @cloud_account.save
post :update, :cloud_account => { :id => @cloud_account.id, :password => 'mockpassword' }
- response.should redirect_to("http://test.host/provider/accounts/#%7B@provider.id%7D")
- response.should redirect_to("http://test.host/providers/accounts/#%7B@provider.id%7D") CloudAccount.find(@cloud_account.id).password.should == "mockpassword" end
@@ -38,7 +38,7 @@ describe CloudAccountsController do lambda do post :destroy, :id => @cloud_account.id end.should change(CloudAccount, :count).by(-1)
- response.should redirect_to("http://test.host/provider/accounts/#%7B@provider.id%7D")
- response.should redirect_to("http://test.host/providers/accounts/#%7B@provider.id%7D") CloudAccount.find(:first, :conditions => ['id = ?', @cloud_account.id]).should be_nil end
diff --git a/src/spec/controllers/provider_controller_spec.rb b/src/spec/controllers/provider_controller_spec.rb index 096af3d..a1a317a 100644 --- a/src/spec/controllers/provider_controller_spec.rb +++ b/src/spec/controllers/provider_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper'
-describe ProviderController do +describe ProvidersController do
fixtures :all before(:each) do -- 1.7.2.3
deltacloud-devel mailing list deltacloud-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/deltacloud-devel