[PATCH conductor] bug 801106: limit pool selection within pool family for catalog edit
Jozef Zigmund
jzigmund at redhat.com
Fri Mar 9 14:23:17 UTC 2012
On Thursday 08 March 2012 23:11:39 Scott Seago wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=801106
> ---
> src/app/controllers/catalogs_controller.rb | 19 ++++++++++++++-----
> 1 files changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/src/app/controllers/catalogs_controller.rb
> b/src/app/controllers/catalogs_controller.rb index 18fa292..a0b8f90 100644
> --- a/src/app/controllers/catalogs_controller.rb
> +++ b/src/app/controllers/catalogs_controller.rb
> @@ -32,9 +32,9 @@ class CatalogsController < ApplicationController
> end
>
> def new
> + @catalog = Catalog.new(params[:catalog]) # ...when should there be
> params on new? load_pools
> require_privilege(Privilege::CREATE, Catalog, @pools.first)
> - @catalog = Catalog.new(params[:catalog]) # ...when should there be
> params on new? @title = t'catalogs.new.add_catalog'
> end
>
> @@ -52,8 +52,8 @@ class CatalogsController < ApplicationController
> end
>
> def create
> - load_pools
> @catalog = Catalog.new(params[:catalog])
> + load_pools
> require_privilege(Privilege::CREATE, Catalog, @catalog.pool)
> if @catalog.save
> flash[:notice] = t('catalogs.flash.notice.created', :count => 1)
> @@ -73,8 +73,10 @@ class CatalogsController < ApplicationController
> def update
> @catalog = Catalog.find(params[:id])
> require_privilege(Privilege::MODIFY, @catalog)
> - require_privilege(Privilege::CREATE, Catalog, @catalog.pool)
> -
> + unless @catalog.pool_id == params[:catalog][:pool_id]
> + require_privilege(Privilege::CREATE, Catalog,
> + Pool.find(params[:catalog][:pool_id]))
> + end
> if @catalog.update_attributes(params[:catalog])
> flash[:notice] = t('catalogs.flash.notice.updated', :count => 1)
> redirect_to catalogs_url
> @@ -136,6 +138,13 @@ class CatalogsController < ApplicationController
> end
>
> def load_pools
> - @pools = Pool.list_for_user(current_user, Privilege::CREATE, Catalog)
> + if @catalog.pool_family
> + @pools = @catalog.pool_family.pools.list_for_user(current_user,
> + Privilege::CREATE,
> + Catalog)
> + @pools.unshift(@catalog.pool) unless @pools.include?(@catalog.pool)
> + else
> + @pools = Pool.list_for_user(current_user, Privilege::CREATE, Catalog)
> + end
> end
> end
ACK, works for me as expected.
More information about the aeolus-devel
mailing list