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
This commit is contained in:
Bo Wang 2016-03-14 11:47:05 +08:00
parent 80a0361a17
commit d9ebebb736

View File

@ -77,14 +77,13 @@ def show_domain_list(context):
@register.inclusion_tag('context_selection/_project_list.html', @register.inclusion_tag('context_selection/_project_list.html',
takes_context=True) takes_context=True)
def show_project_list(context): def show_project_list(context):
max_proj = getattr(settings, max_proj = getattr(settings, 'DROPDOWN_MAX_ITEMS', 30)
'DROPDOWN_MAX_ITEMS',
30)
if 'request' not in context: if 'request' not in context:
return {} return {}
request = context['request'] request = context['request']
context = {'projects': sorted(context['authorized_tenants'], projects = sorted(context['authorized_tenants'],
key=lambda project: project.name)[:max_proj], key=lambda project: project.name.lower())
context = {'projects': projects[:max_proj],
'project_id': request.user.project_id, 'project_id': request.user.project_id,
'request': request} 'request': request}
return context return context
@ -97,7 +96,8 @@ def show_region_list(context):
return {} return {}
request = context['request'] request = context['request']
context = {'region_name': request.user.services_region, 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} 'request': request}
return context return context