[PATCH conductor 1/2] BZ 806846 ImageController: removed duplicate code, fixed flash displaying

Tomáš Hrčka thrcka at redhat.com
Fri May 25 08:09:29 UTC 2012


On 05/24/2012 05:44 PM, jzigmund at redhat.com wrote:
> From: Jozef Zigmund<jzigmund at redhat.com>
>
> ---
>   src/app/controllers/images_controller.rb |   15 ++++++---------
>   src/config/locales/en.yml                |    2 +-
>   2 files changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/src/app/controllers/images_controller.rb b/src/app/controllers/images_controller.rb
> index 8c38a57..8566191 100644
> --- a/src/app/controllers/images_controller.rb
> +++ b/src/app/controllers/images_controller.rb
> @@ -64,8 +64,6 @@ class ImagesController<  ApplicationController
>       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 @@ class ImagesController<  ApplicationController
>     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
> diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
> index 7b1ca00..e8c91a3 100644
> --- a/src/config/locales/en.yml
> +++ b/src/config/locales/en.yml
> @@ -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:
ACK. to the patch set.



More information about the aeolus-devel mailing list