Mohammed Morsi wrote:
> ---
> src/app/controllers/portal_pool_controller.rb | 6 ++++
> src/app/controllers/provider_controller.rb | 6 ++++
> src/app/controllers/realms_controller.rb | 39
> +++++++++++++++++++++++++
> src/app/models/portal_pool.rb | 4 ++
> src/app/views/portal_pool/realms.html.erb | 1 +
> src/app/views/provider/realms.html.erb | 1 +
> src/app/views/realms/_list.html.erb | 20 +++++++++++++
> src/app/views/realms/index.html.erb | 1 +
> 8 files changed, 78 insertions(+), 0 deletions(-)
> create mode 100644 src/app/controllers/realms_controller.rb
> create mode 100644 src/app/views/portal_pool/realms.html.erb
> create mode 100644 src/app/views/provider/realms.html.erb
> create mode 100644 src/app/views/realms/_list.html.erb
> create mode 100644 src/app/views/realms/index.html.erb
>
> diff --git a/src/app/controllers/portal_pool_controller.rb
> b/src/app/controllers/portal_pool_controller.rb
> index 90df8a5..21ceaf2 100644
> --- a/src/app/controllers/portal_pool_controller.rb
> +++ b/src/app/controllers/portal_pool_controller.rb
> @@ -38,6 +38,12 @@ class PortalPoolController < ApplicationController
> @instances = @pool.instances
> end
>
> + def realms
> + @pool = PortalPool.find(params[:id])
> + @realms = @pool.providers.collect { |pr| pr.realms }.flatten
>
You'll want to call Realms on @pool: @pool.realms. For all of the pool
views we want the "front end" resources (i.e. realms, images, HW
Profiles defined on the pool), not those that happen to be defined on
the back end accounts. Realm is a bit of a special case as realms is a
method that returns a list of strings, since pool realms are
auto-generated from the back end realms (unlike HWP and Images which
have an explicit mapping table)
> + require_privilege(Privilege::INSTANCE_VIEW,@pool)
>
I think we should use POOL_VIEW here. POOL_VIEW would be the default
privilege for viewing pool resources except for those with more
specialized privileges defined (quotas, instances, accounts)
> + end
> +
> def new
> require_privilege(Privilege::POOL_MODIFY)
> @portal_pool = PortalPool.new
> diff --git a/src/app/controllers/provider_controller.rb
> b/src/app/controllers/provider_controller.rb
> index 53056f5..ac703c0 100644
> --- a/src/app/controllers/provider_controller.rb
> +++ b/src/app/controllers/provider_controller.rb
> @@ -32,6 +32,12 @@ class ProviderController < ApplicationController
> require_privilege(Privilege::PROVIDER_VIEW, @provider)
> end
>
> + def realms
> + @provider = Provider.find(params[:id])
> + @realms = @provider.realms
> + require_privilege(Privilege::PROVIDER_VIEW, @provider)
> + end
> +
> def new
> require_privilege(Privilege::PROVIDER_MODIFY)
> @provider = Provider.new(params[:provider])
> diff --git a/src/app/controllers/realms_controller.rb
> b/src/app/controllers/realms_controller.rb
> new file mode 100644
> index 0000000..667279c
> --- /dev/null
> +++ b/src/app/controllers/realms_controller.rb
> @@ -0,0 +1,39 @@
> +# Copyright (C) 2010 Red Hat, Inc.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; version 2 of the License.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
> +# MA 02110-1301, USA. A copy of the GNU General Public License is
> +# also available at http://www.gnu.org/copyleft/gpl.html.
> +
> +# Filters added to this controller apply to all controllers in the
> application.
> +# Likewise, all the methods added will be available for all controllers.
> +
> +require 'util/taskomatic'
> +
>
I don't think you need to include taskomatic here
> +class RealmsController < ApplicationController
> + before_filter :require_user
> +
> + def index
> + @realms = Realm.find(:all)
> + #require_privilege(Privilege::PROVIDER_VIEW, @realms) ?
> + end
> +
>
I'm not sure we need to support listing all realms regardless of what
provider they belong to, as realms don't really make sense apart from
the provider and/or pool.
> + def new
> + end
> +
> + def create
> + end
> +
> + def delete
> + end
> +end
> diff --git a/src/app/models/portal_pool.rb b/src/app/models/portal_pool.rb
> index 28b700e..81de037 100644
> --- a/src/app/models/portal_pool.rb
> +++ b/src/app/models/portal_pool.rb
> @@ -40,6 +40,10 @@ class PortalPool < ActiveRecord::Base
> :include => [:role],
> :order => "permissions.id ASC"
>
> + def providers
> + cloud_accounts.collect { |ca| ca.provider }
> + end
> +
>
If you're not doing the provider iteration above, you can probably get
rid of this one for now.
> def realms
> realm_list = []
> cloud_accounts.each do |cloud_account|
> diff --git a/src/app/views/portal_pool/realms.html.erb
> b/src/app/views/portal_pool/realms.html.erb
> new file mode 100644
> index 0000000..3aca533
> --- /dev/null
> +++ b/src/app/views/portal_pool/realms.html.erb
> @@ -0,0 +1 @@
> +<%= render :partial => 'realms/list' %>
> diff --git a/src/app/views/provider/realms.html.erb
> b/src/app/views/provider/realms.html.erb
> new file mode 100644
> index 0000000..3aca533
> --- /dev/null
> +++ b/src/app/views/provider/realms.html.erb
> @@ -0,0 +1 @@
> +<%= render :partial => 'realms/list' %>
> diff --git a/src/app/views/realms/_list.html.erb
> b/src/app/views/realms/_list.html.erb
> new file mode 100644
> index 0000000..c95fac3
> --- /dev/null
> +++ b/src/app/views/realms/_list.html.erb
> @@ -0,0 +1,20 @@
> +<% if @realms.size == 0 %>
> +<h1>There are no realms to display</h1>
> +<% else %>
> + <table>
> + <thead>
> + <tr>
> + <th scope="col">Name</th>
> + <th scope="col">Provider</th>
>
So once this is reformulated to show realms for the pool the provider
name will go away here.
> + </tr>
> + </thead>
> + <tbody>
> + <%[email protected] {|realm| %>
> + <tr>
> + <td><%= realm.name %></td>
> + <td><%= realm.provider.name %></td>
> + </tr>
> + <% } %>
> + </tbody>
> + </table>
> +<% end %>
> diff --git a/src/app/views/realms/index.html.erb
> b/src/app/views/realms/index.html.erb
> new file mode 100644
> index 0000000..c19c3fa
> --- /dev/null
> +++ b/src/app/views/realms/index.html.erb
> @@ -0,0 +1 @@
> +<%= render :partial => 'list' %>
>
Scott
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel