[Ovirt-devel] [PATCH server] Random cleanup/cloud UI prep.

Scott Seago sseago at redhat.com
Wed May 13 14:33:35 UTC 2009


Jason Guiditta wrote:
> This patch fixes a bunch of errors in the tests, and adds
> a few model methods that will be used in the upcoming Cloud UI V1
> patch.
>
> Signed-off-by: Jason Guiditta <jguiditt at redhat.com>
> ---
> diff --git a/src/app/models/vm.rb b/src/app/models/vm.rb
> index 6880c22..f2e53ed 100644
> --- a/src/app/models/vm.rb
> +++ b/src/app/models/vm.rb
> @@ -380,6 +380,19 @@ class Vm < ActiveRecord::Base
>      return i
>    end
>  
> +  # Make method for calling paginated vms easier for clients.
> +  # TODO: Might want to have an optional param for per_page var
> +  def self.paged_with_perms(user, priv, page, order)
> +    Vm.paginate(:include => [{:vm_resource_pool =>
> +                              {:permissions => {:role => :privileges}}}],
> +                :conditions => ["privileges.name=:priv
> +                           and permissions.uid=:user",
> +                         { :user => user, :priv => priv }],
> +                :per_page => 5,
> +                :page => page,
> +                :order => order)
> +  end
> +
>   
OK just one comment here,

I wonder if we should somehow incorporate this logic into the index 
controller/service layer action, since logically this action corresponds 
to VmController.index. Although since you're not using VmController 
maybe you could consider implementing svc_index in VmService (which 
would call this) and then pulling out the almost-identical logic in 
VmController.index

I'll try to test this a bit later -- and actually the comment above 
isn't so much about this patch but rather about how we use this method 
in the controllers later anyway.

Scott




More information about the ovirt-devel mailing list