On 03/18/2010 02:39 PM, Scott Seago wrote:
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)
Ah, hadn't noticed that method. Was looking for a has_many :realms and/or a portal_pool_id column in the realms 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
Had just copied the portal pool controller over (which still includes taskomatic) and made changes. Removed both requires in the updated patch.
+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.
We're really not losing anything here either. The realm views should really go into their own app/views/realms dir, and since we have that, an extra controller / action is trivial. In the interest of getting this in though, removed.
- 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.
Removed.
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.
Removed.
</tr>
</thead>
<tbody>
- <%@realms.each {|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
Update patch sent.
-Mo