On 04/01/2014 04:50 AM, Royce Lv wrote:
On 2014年03月28日 10:14, Rodrigo Trujillo wrote:
> This patch sorts the host partitions list returned by backend by
> partition path. Then UI is going to show paths sorted, improving
> the user experience.
>
> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
> ---
> src/kimchi/control/host.py | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py
> index cfc24bd..d4387f4 100644
> --- a/src/kimchi/control/host.py
> +++ b/src/kimchi/control/host.py
> @@ -20,7 +20,7 @@
> import cherrypy
>
> from kimchi.control.base import Collection, Resource
> -from kimchi.control.utils import UrlSubNode, validate_method
> +from kimchi.control.utils import UrlSubNode, validate_method, model_fn
> from kimchi.exception import OperationFailed
> from kimchi.template import render
>
> @@ -64,6 +64,24 @@ class Partitions(Collection):
> super(Partitions, self).__init__(model)
> self.resource = Partition
>
> + # Defining get_resources in order to return list of partitions
> in UI
> + # sorted by their path
> + def _get_resources(self, flag_filter):
> + try:
> + get_list = getattr(self.model, model_fn(self, 'get_list'))
> + idents = get_list(*self.model_args, **flag_filter)
> + res_list = []
> + for ident in idents:
> + # internal text, get_list changes ident to unicode
> for sorted
> + args = self.resource_args + [ident]
> + res = self.resource(self.model, *args)
> + res.lookup()
> + res_list.append(res)
> + # Sort by partition path
> + res_list.sort(key=lambda x: x.info['path'])
> + return res_list
> + except AttributeError:
> + return []
>
> class Partition(Resource):
> def __init__(self, model, id):
What about override this method by calling base _get_resources() first
then sort?
res_list = super(Partitions, self).__get_resources(flag_filter)
res_list.sort(...)
return res_list
Wow... good idea.
Thanks Royce
_______________________________________________
Kimchi-devel mailing list
Kimchi-devel(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel