From 02b6c1b405d779d2df7897bf67bc39133069d0e6 Mon Sep 17 00:00:00 2001 From: wangliangyu Date: Fri, 9 Nov 2018 10:19:28 +0800 Subject: [PATCH] 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 --- horizon/tables/views.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/horizon/tables/views.py b/horizon/tables/views.py index 172e979a37..d52acf4d8f 100644 --- a/horizon/tables/views.py +++ b/horizon/tables/views.py @@ -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