On 05/04/2012 04:07 PM, jprovazn(a)redhat.com wrote:
From: Jan Provaznik<jprovazn(a)redhat.com>
If a deployable referenced images which didn't exist, deployables 'show'
action
didn't respond properly to json requests. This patch:
- fixes 'show' action to always respond to json requests
- updates html_error_page method to set error flash message only for 'now', error
page
doesn't do redirect
- removes flash setting in handle_general_error method - this method calls
html_error_page
which sets flash message anyway
Auto-updating of deploaybles show page is still not ideal - status is not updated if a
deploayble
has missing images and then this images are added/fixed - this is out of scope of this
BZ.
---
src/app/controllers/application_controller.rb | 3 +-
src/app/controllers/deployables_controller.rb | 28 ++++++++++++------------
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/src/app/controllers/application_controller.rb
b/src/app/controllers/application_controller.rb
index a1bd60f..803362c 100644
--- a/src/app/controllers/application_controller.rb
+++ b/src/app/controllers/application_controller.rb
@@ -69,7 +69,6 @@ class ApplicationController< ActionController::Base
end
def handle_general_error(error)
- flash[:error] = error.message
handle_error(:error => error, :status => :internal_server_error,
:title =>
t('application_controller.internal_server_error'))
end
@@ -92,7 +91,7 @@ class ApplicationController< ActionController::Base
render :partial => 'layouts/popup-error', :status => status,
:locals => {:title => title, :errmsg => msg}
else
- flash[:error] = msg
+ flash.now[:error] = msg
render :template => 'layouts/error', :layout =>
'application',
:locals => {:title => title, :errmsg => ''}
end
diff --git a/src/app/controllers/deployables_controller.rb
b/src/app/controllers/deployables_controller.rb
index 8967e79..d3dab36 100644
--- a/src/app/controllers/deployables_controller.rb
+++ b/src/app/controllers/deployables_controller.rb
@@ -79,20 +79,20 @@ class DeployablesController< ApplicationController
@images_details, images, @missing_images, @deployable_errors =
@deployable.get_image_details
flash.now[:error] = @deployable_errors unless @deployable_errors.empty?
- return unless @missing_images.empty?
-
- @build_results = {}
- @pushed_count = 0
- ProviderAccount.includes(:provider,
:pool_families).where('providers.enabled' => true, 'pool_families.id'
=> @deployable.catalogs.first.pool_family.id).each do |account|
- type = account.provider.provider_type.deltacloud_driver
- @build_results[type] ||= []
- status = @deployable.build_status(images, account)
- @pushed_count += 1 if (status == :pushed)
- @build_results[type]<< {
- :account => account.label,
- :provider => account.provider.name,
- :status => status,
- }
+ if @missing_images.empty?
+ @build_results = {}
+ @pushed_count = 0
+ ProviderAccount.includes(:provider,
:pool_families).where('providers.enabled' => true, 'pool_families.id'
=> @deployable.catalogs.first.pool_family.id).each do |account|
+ type = account.provider.provider_type.deltacloud_driver
+ @build_results[type] ||= []
+ status = @deployable.build_status(images, account)
+ @pushed_count += 1 if (status == :pushed)
+ @build_results[type]<< {
+ :account => account.label,
+ :provider => account.provider.name,
+ :status => status,
+ }
+ end
end
respond_to do |format|
ACK
Jirka