Make table filters valid for every languages

As we known, the table support filtered by local language
with some filters mapping, like below:
https://github.com/openstack/horizon/blob/master/openstack_dashboard/dashboards/project/networks/views.py#L46
We use the filter string given by user and look valid values
in those filters mapping. But the keys in filters mapping,
which is django.utils.functional.__proxy__, does not match
the filter string.
This commit valid them.

Change-Id: I40cb50bbf08fc457967615f2654026cfdafb9232
Closes-Bug: #1802228
This commit is contained in:
wangliangyu 2018-11-09 10:19:28 +08:00
parent 21b581b49f
commit 02b6c1b405
1 changed files with 7 additions and 5 deletions

View File

@ -304,11 +304,13 @@ class DataTableView(MultiTableView):
filter_string = self.table.get_filter_string().strip()
if filter_field and filter_string:
filter_map = filters_map.get(filter_field, {})
# We use the filter_string given by the user and
# look for valid values in the filter_map that's why
# we apply lower()
filters[filter_field] = filter_map.get(
filter_string.lower(), filter_string)
filters[filter_field] = filter_string
for k, v in filter_map.items():
# k is django.utils.functional.__proxy__
# and could not be searched in dict
if filter_string.lower() == k:
filters[filter_field] = v
break
return filters