From: Jan Provaznik <[email protected]>

---
 .../controllers/resources/instances_controller.rb  |   14 ++++++--------
 src/app/views/resources/instances/_list.haml       |    2 +-
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/app/controllers/resources/instances_controller.rb 
b/src/app/controllers/resources/instances_controller.rb
index 95dc34e..f5e4786 100644
--- a/src/app/controllers/resources/instances_controller.rb
+++ b/src/app/controllers/resources/instances_controller.rb
@@ -1,5 +1,6 @@
 class Resources::InstancesController < ApplicationController
   before_filter :require_user
+  before_filter :instance, :only => [:show, :remove_failed, :key, :stop]
 
   def new
     @instance = Instance.new(params[:instance])
@@ -61,8 +62,6 @@ class Resources::InstancesController < ApplicationController
   end
 
   def show
-    @instance = Instance.find((params[:id] || []).first)
-    require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
     @url_params = params.clone
     @tab_captions = ['Properties', 'History', 'Permissions']
     @details_tab = params[:details_tab].blank? ? 'properties' : 
params[:details_tab]
@@ -96,8 +95,6 @@ class Resources::InstancesController < ApplicationController
   end
 
   def key
-    @instance = Instance.find((params[:id] || []).first)
-    require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
     unless @instance.instance_key.nil?
       send_data @instance.instance_key.pem,
                 :filename => "#[email protected]_key.name}.pem",
@@ -109,8 +106,6 @@ class Resources::InstancesController < ApplicationController
   end
 
   def stop
-    @instance = Instance.find((params[:ids] || []).first)
-    require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
     unless @instance.valid_action?('stop')
       raise ActionError.new("stop is an invalid action.")
     end
@@ -127,8 +122,6 @@ class Resources::InstancesController < ApplicationController
   end
 
   def remove_failed
-    @instance = Instance.find((params[:ids] || []).first)
-    require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
     raise ActionError.new("remove failed cannot be performed on this 
instance.") unless
       @instance.state == Instance::STATE_ERROR
     condormatic_instance_reset_error(@instance)
@@ -138,6 +131,11 @@ class Resources::InstancesController < 
ApplicationController
 
   private
 
+  def instance
+    @instance = Instance.find((params[:id] || []).first)
+    require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
+  end
+
   def init_new_instance_attrs
     @pools = Pool.list_for_user(@current_user, Privilege::INSTANCE_MODIFY)
     @realms = Realm.find(:all, :conditions => { :provider_id => nil })
diff --git a/src/app/views/resources/instances/_list.haml 
b/src/app/views/resources/instances/_list.haml
index d0277ac..a83b565 100644
--- a/src/app/views/resources/instances/_list.haml
+++ b/src/app/views/resources/instances/_list.haml
@@ -14,7 +14,7 @@
       %tr
         %td
           - selected = params[:select] == 'all'
-          %input{:checked => selected, :name => 'ids', :type => 'checkbox', 
:value => inst.id, :id => "inst_ids_#{inst.id}" }
+          %input{:checked => selected, :name => 'id', :type => 'checkbox', 
:value => inst.id, :id => "inst_ids_#{inst.id}" }
           = link_to inst.name, resources_instance_path(inst)
         %td= inst.state
         %td= inst.template.name
-- 
1.7.2.3

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

Reply via email to