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 <sseago(a)redhat.com>
---
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 c898691..159aab8 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::POOL_VIEW)
+ # 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
Show replies by date