Permalink
Browse files

BZ 806846 ImageController: removed duplicate code, fixed flash displa…

…ying
  • Loading branch information...
1 parent bdc6f3e commit 144afb2834b7589e6a1860b846c2ee5c6913eb93 @jzigmund jzigmund committed May 24, 2012
Showing with 7 additions and 10 deletions.
  1. +6 −9 src/app/controllers/images_controller.rb
  2. +1 −1 src/config/locales/en.yml
@@ -64,8 +64,6 @@ def show
load_builds
load_target_images(@build)
@target_image_exists = @target_images_by_target.any?
- @account_groups_listing = @account_groups.select{ |driver, group| group[:included] || @target_images_by_target[driver] || (@build and @builder.find_active_build(@build.id, driver)) }
- flash[:error] = t("images.flash.error.no_provider_accounts") if @account_groups_listing.blank?
@user_can_build =
(@environment && check_privilege(Privilege::USE, @environment))
@@ -168,14 +166,13 @@ def template
def new
@environment = PoolFamily.find(params[:environment])
check_permissions
- if 'import' == params[:tab]
- @accounts = @environment.provider_accounts.enabled.list_for_user(current_user, Privilege::USE)
- if !@accounts.any?
- flash[:error] = t("images.flash.error.no_provider_accounts_for_import")
- end
- render :import and return
+ @accounts = @environment.provider_accounts.enabled.list_for_user(current_user, Privilege::USE)
+ if @accounts.empty?
+ flash.now[:error] = params[:tab] == 'import' ?
+ t("images.flash.error.no_provider_accounts_for_import") :
+ t("images.flash.error.no_provider_accounts")
end
-
+ render 'import' == params[:tab] ? :import : :new
end
def import
@@ -865,7 +865,7 @@ en:
no_file: You must specify the template XML file
no_template: "The image doesn't have a template because it's been imported."
no_provider_accounts: "Images cannot be built, as there are no enabled Provider Accounts associated to this Environment."
- no_provider_accounts_for_import: Images cannot be imported, as no provider accounts are currently enabled for this environment.
+ no_provider_accounts_for_import: "Images cannot be imported, as no Provider Accounts are currently enabled for this Environment."
new:
new_image: New Image
description:

0 comments on commit 144afb2

Please sign in to comment.