[Ovirt-devel] [PATCH server] Stubs/comments for some validation.

Jason Guiditta jguiditt at redhat.com
Thu Nov 20 20:24:31 UTC 2008


These are a few spots I noticed when I was working on the test
revamp, wanted to try and catch them before they were forgotten,
but not enough time to actually implement.

Signed-off-by: Jason Guiditta <jguiditt at redhat.com>
---
 src/app/models/host.rb |    1 +
 src/app/models/pool.rb |    8 +++++++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/app/models/host.rb b/src/app/models/host.rb
index 429f0c0..743ec6e 100644
--- a/src/app/models/host.rb
+++ b/src/app/models/host.rb
@@ -51,6 +51,7 @@ class Host < ActiveRecord::Base
                              [ :search_users, 'U', "search_users" ] ],
                  :eager_load => :smart_pools
 
+  #FIXME: add validations to prevent sending back db errors, such as 'number too large'
 
   KVM_HYPERVISOR_TYPE = "KVM"
   HYPERVISOR_TYPES = [KVM_HYPERVISOR_TYPE]
diff --git a/src/app/models/pool.rb b/src/app/models/pool.rb
index 7034e79..0319d08 100644
--- a/src/app/models/pool.rb
+++ b/src/app/models/pool.rb
@@ -45,6 +45,7 @@ class Pool < ActiveRecord::Base
   has_many :smart_pool_tags, :as => :tagged, :dependent => :destroy
   has_many :smart_pools, :through => :smart_pool_tags
 
+  before_destroy :check_for_children
   # used to allow parent traversal before obj is saved to the db
   # (needed for view code 'create' form)
   attr_accessor :tmp_parent
@@ -307,6 +308,7 @@ class Pool < ActiveRecord::Base
   def class_and_id
     self.class.name + "_" + self.id.to_s
   end
+
   protected
   def traverse_parents
     if id
@@ -323,5 +325,9 @@ class Pool < ActiveRecord::Base
     return nil
   end
 
-
+  private
+  def check_for_children
+    #TODO: look for children and abort destroy if they exist.
+    #This may also require some functionality to be added to controllers and such.
+  end
 end
-- 
1.5.6.5




More information about the ovirt-devel mailing list