ACK on this.

Everything seems to work fine,

Couple of thoughts:

Probably doesn't matter too much since TaskOMatic is going, but the 
instance_create method seems to have accumulated into a very long sequence of 
code which makes it difficult to follow and maintain, it would be nicer if it 
was broken down into smaller more digestible methods.

It could be possible to add the bits of code necessary for running with two 
providers in a rake task, just to make it a little easier to setup.

Cheers

Martyn


----- Original Message -----
From: "Scott Seago" <[email protected]>
To: [email protected]
Sent: Friday, June 4, 2010 5:24:01 AM GMT +00:00 GMT Britain, Ireland, Portugal
Subject: [deltacloud-devel] [PATCH aggregator 2/2] don't ask user to select 
pool if it's already done via the URL/link

In addition, if a user only has permission on one pool, there's no need to ask 
the user to select it.

Signed-off-by: Scott Seago <[email protected]>
---
 src/app/controllers/instance_controller.rb |    3 +++
 src/app/views/instance/new.html.erb        |    9 +++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/app/controllers/instance_controller.rb 
b/src/app/controllers/instance_controller.rb
index cfd1856..e884655 100644
--- a/src/app/controllers/instance_controller.rb
+++ b/src/app/controllers/instance_controller.rb
@@ -41,6 +41,9 @@ class InstanceController < ApplicationController
     @instance = Instance.new(params[:instance])
     require_privilege(Privilege::INSTANCE_MODIFY, @instance.pool) if 
@instance.pool
     @pools = Pool.list_for_user(@current_user, Privilege::INSTANCE_MODIFY)
+    # FIXME: what error msg to show if no pool is selected and the user has
+    # permission on none?
+    @instance.pool = @pools[0] if (@instance.pool.nil? and (@pools.size == 1))
   end
 
   def create
diff --git a/src/app/views/instance/new.html.erb 
b/src/app/views/instance/new.html.erb
index 74096a2..0553a42 100644
--- a/src/app/views/instance/new.html.erb
+++ b/src/app/views/instance/new.html.erb
@@ -39,12 +39,21 @@
     </li>
     <input type=hidden name="instance[image_id]" value="<%= @instance.image ? 
@instance.image.id : '' %>">
 
+    <% if @instance.pool %>
+    <input type=hidden name="instance[pool_id]" value="<%= @instance.pool_id 
%>">
+      <% if (@pools.size > 1) %>
+        <li><label>Pool</label>
+          <%= @instance.pool.name %>
+        </li>
+      <% end %>
+    <% else %>
     <li><label>Pool<span>Pick your pool</span></label>
       <%= select("instance", "pool_id",
                  @pools.collect {|p| [ p.name, p.id ] },
                  { :include_blank => true },
                  {:onchange => "poolSelected(this)"}) %>
     </li>
+    <% end %>
 
     <% if @instance.pool and @instance.pool.hardware_profiles.size > 0 %>
       <li><label>Hardware Profile<span>Pick your hardware 
profile</span></label>
-- 
1.6.2.5

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to