[PATCH] BZ 816170 check if image can be found at the beginning of 'show'

Matt Wagner matt.wagner at redhat.com
Wed Aug 29 20:13:35 UTC 2012


On Fri, Aug 17, 2012 at 07:17:11AM -0400, Tzu-Mainn Chen wrote:
> ---
>  src/app/controllers/images_controller.rb |    5 +++++
>  src/config/locales/en.yml                |    1 +
>  2 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/src/app/controllers/images_controller.rb b/src/app/controllers/images_controller.rb
> index d9ab289..a872347 100644
> --- a/src/app/controllers/images_controller.rb
> +++ b/src/app/controllers/images_controller.rb
> @@ -38,6 +38,11 @@ class ImagesController < ApplicationController
>  
>    def show
>      @image = Aeolus::Image::Warehouse::Image.find(params[:id])
> +    if @image.nil?
> +      redirect_to images_path
> +      flash[:error] = t('images.flash.error.not_exist')
> +      return
> +    end
>      @environment = PoolFamily.where('name' => @image.environment).first
>      require_privilege(Privilege::VIEW, @environment)
>      @push_started = params[:push_started] == 'true'
> diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
> index dc38241..e019980 100644
> --- a/src/config/locales/en.yml
> +++ b/src/config/locales/en.yml
> @@ -968,6 +968,7 @@ en:
>          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."
> +        not_exist: "The image you tried to access cannot be found, it may have been deleted"
>      new:
>        new_image: New Image
>        description:
> -- 
> 1.7.6.5

ACK + pushed. Will update BZ and 1.1 as well.

-- Matt



More information about the aeolus-devel mailing list