From d9ebebb736fef29d559511690e0c393607ce4311 Mon Sep 17 00:00:00 2001 From: Bo Wang Date: Mon, 14 Mar 2016 11:47:05 +0800 Subject: [PATCH] Make region list case-insensitive sorted Function sorted() output the result as ASCII sequence in default. sorted(['Region1', 'myregion']) will not change sequence. Fix it for tenant list too. Change-Id: I2e4e546ac70af1f758b618cf253f518a475b8392 Closes-Bug: #1439791 --- .../templatetags/context_selection.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openstack_dashboard/templatetags/context_selection.py b/openstack_dashboard/templatetags/context_selection.py index 164bd577b8..bf0c861893 100644 --- a/openstack_dashboard/templatetags/context_selection.py +++ b/openstack_dashboard/templatetags/context_selection.py @@ -77,14 +77,13 @@ def show_domain_list(context): @register.inclusion_tag('context_selection/_project_list.html', takes_context=True) def show_project_list(context): - max_proj = getattr(settings, - 'DROPDOWN_MAX_ITEMS', - 30) + max_proj = getattr(settings, 'DROPDOWN_MAX_ITEMS', 30) if 'request' not in context: return {} request = context['request'] - context = {'projects': sorted(context['authorized_tenants'], - key=lambda project: project.name)[:max_proj], + projects = sorted(context['authorized_tenants'], + key=lambda project: project.name.lower()) + context = {'projects': projects[:max_proj], 'project_id': request.user.project_id, 'request': request} return context @@ -97,7 +96,8 @@ def show_region_list(context): return {} request = context['request'] context = {'region_name': request.user.services_region, - 'regions': sorted(request.user.available_services_regions), + 'regions': sorted(request.user.available_services_regions, + key=lambda x: x.lower()), 'request': request} return context