Fix AttributeError in context_selection.py

When create a service with region = None,

File "/openstack_dashboard/templatetags/context_selection.py", line 100,
in <lambda>
AttributeError: 'NoneType' object has no attribute 'lower'

The problem code:

    sorted(request.user.available_services_regions,
           key=lambda x: x.lower())

To fix this, if region is NoneType, use '' as key to put it first in the
list.

Change-Id: Ide8eaeeee634bf1933ef263d3b27204c7711d167
Closes-Bug: #1581667
This commit is contained in:
Yosef Hoffman 2016-05-16 09:02:17 -04:00
parent 79c2729d5a
commit da2e93578f

View File

@ -100,7 +100,7 @@ def show_region_list(context):
request = context['request']
context = {'region_name': request.user.services_region,
'regions': sorted(request.user.available_services_regions,
key=lambda x: x.lower()),
key=lambda x: (x or '').lower()),
'page_url': request.horizon.get('panel').get_absolute_url()}
return context