--- src/app/controllers/portal_pool_controller.rb | 8 ++++++-- src/app/controllers/provider_controller.rb | 6 ++++++ src/app/views/portal_pool/realms.html.erb | 1 + src/app/views/portal_pool/show.html.erb | 1 + src/app/views/provider/realms.html.erb | 1 + src/app/views/provider/show.html.erb | 1 + src/app/views/realms/_list.html.erb | 18 ++++++++++++++++++ 7 files changed, 34 insertions(+), 2 deletions(-) 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
diff --git a/src/app/controllers/portal_pool_controller.rb b/src/app/controllers/portal_pool_controller.rb index 5e42d55..3138158 100644 --- a/src/app/controllers/portal_pool_controller.rb +++ b/src/app/controllers/portal_pool_controller.rb @@ -19,8 +19,6 @@ # 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' - class PortalPoolController < ApplicationController before_filter :require_user
@@ -44,6 +42,12 @@ class PortalPoolController < ApplicationController require_privilege(Privilege::POOL_VIEW, @pool) end
+ def realms + @pool = PortalPool.find(params[:id]) + @realms = @pool.realms + require_privilege(Privilege::POOL_VIEW,@pool) + 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 b676fa7..0436aee 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/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/portal_pool/show.html.erb b/src/app/views/portal_pool/show.html.erb index 5a29875..cdd9e5d 100644 --- a/src/app/views/portal_pool/show.html.erb +++ b/src/app/views/portal_pool/show.html.erb @@ -37,3 +37,4 @@ <% end %> <%= link_to "Add a new instance", {:controller => "instance", :action => "new", :id => @pool}, :class=>"actionlink"%> <%= link_to "Hardware Profiles", {:action => "hardware_profiles", :id => @pool.id}, :class=>"actionlink"%> +<%= link_to "Realms", {:action => "realms", :id => @pool.id}, :class=>"actionlink"%> 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/provider/show.html.erb b/src/app/views/provider/show.html.erb index 299346f..884ce81 100644 --- a/src/app/views/provider/show.html.erb +++ b/src/app/views/provider/show.html.erb @@ -19,6 +19,7 @@ </table> <% end %> <%= link_to "Add a pool", {:controller => "portal_pool", :action => "new", :provider => @provider}, :class => "actionlink" %> +<%= link_to "Realms", {:action => "realms", :id => @provider.id}, :class=>"actionlink"%> <% form_tag :action => 'destroy' do %> <%=hidden_field :provider, :id %> <%= submit_tag "Delete Provider", :class => "submit_link" %> diff --git a/src/app/views/realms/_list.html.erb b/src/app/views/realms/_list.html.erb new file mode 100644 index 0000000..49fcd36 --- /dev/null +++ b/src/app/views/realms/_list.html.erb @@ -0,0 +1,18 @@ +<% if @realms.size == 0 %> +<h1>There are no realms to display</h1> +<% else %> + <table> + <thead> + <tr> + <th scope="col">Name</th> + </tr> + </thead> + <tbody> + <%@realms.each {|realm| %> + <tr> + <td><%= realm.name %></td> + </tr> + <% } %> + </tbody> + </table> +<% end %>
--- .../controllers/portal_pool_controller_spec.rb | 10 ++++++++++ src/spec/controllers/provider_controller_spec.rb | 9 +++++++++ src/spec/factories/provider.rb | 8 ++++++++ src/spec/factories/realm.rb | 13 +++++++++++++ 4 files changed, 40 insertions(+), 0 deletions(-) create mode 100644 src/spec/factories/realm.rb
diff --git a/src/spec/controllers/portal_pool_controller_spec.rb b/src/spec/controllers/portal_pool_controller_spec.rb index 512127d..b8ac1e8 100644 --- a/src/spec/controllers/portal_pool_controller_spec.rb +++ b/src/spec/controllers/portal_pool_controller_spec.rb @@ -39,5 +39,15 @@ describe PortalPoolController do response.should render_template("hardware_profiles") end
+ it "should provide ui to view realms" do + UserSession.create(@admin) + pool = Factory :tpool + + get :realms, :id => pool.id + response.should be_success + assigns[:realms].size.should == pool.realms.size + response.should render_template("realms") + end +
end diff --git a/src/spec/controllers/provider_controller_spec.rb b/src/spec/controllers/provider_controller_spec.rb index ed0036f..f6f61f7 100644 --- a/src/spec/controllers/provider_controller_spec.rb +++ b/src/spec/controllers/provider_controller_spec.rb @@ -41,5 +41,14 @@ describe ProviderController do response.should render_template("hardware_profiles") end
+ it "should provide ui to view realms" do + UserSession.create(@admin) + provider = @admin_permission.permission_object + + get :realms, :id => provider.id + response.should be_success + assigns[:realms].size.should == provider.realms.size + response.should render_template("realms") + end
end diff --git a/src/spec/factories/provider.rb b/src/spec/factories/provider.rb index f349be3..90976ff 100644 --- a/src/spec/factories/provider.rb +++ b/src/spec/factories/provider.rb @@ -6,4 +6,12 @@ Factory.define :mock_provider, :parent => :provider do |p| p.cloud_type 'mock' p.url 'http://localhost:3001/api' p.hardware_profiles { |hp| [hp.association(:mock_hwp1), hp.association(:mock_hwp2)] } + p.after_create { |p| p.realms << Factory(:realm1, :provider => p) << Factory(:realm2, :provider => p) } +end + +Factory.define :mock_provider2, :parent => :provider do |p| + p.name 'mock2' + p.cloud_type 'mock' + p.url 'http://localhost:3001/api' + p.after_create { |p| p.realms << Factory(:realm3, :provider => p) } end diff --git a/src/spec/factories/realm.rb b/src/spec/factories/realm.rb new file mode 100644 index 0000000..93a6516 --- /dev/null +++ b/src/spec/factories/realm.rb @@ -0,0 +1,13 @@ +Factory.define :realm do |r| + r.sequence(:name) { |n| "realm#{n}" } + r.sequence(:external_key) { |n| "key#{n}" } +end + +Factory.define :realm1, :parent => :realm do |r| +end + +Factory.define :realm2, :parent => :realm do |r| +end + +Factory.define :realm3, :parent => :realm do |r| +end
deltacloud-devel@lists.fedorahosted.org