From d4fb80f50052387ded2a5e536e192da88f7f7332 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Thu, 18 Dec 2014 15:14:36 +0100 Subject: [PATCH] Fix TemplateSyntaxError in the server-side filetring of node list views The server-side filtering had two bugs: * the ip_address is not always available for all nodes * the fileds used for filtering were not always strings In addition, I replaced the obsolete glyphicons icon with a Font Awesome icon for filter. Change-Id: I21f4ba835b536d1a179d1af696c2619f25692cc7 --- tuskar_ui/api/node.py | 8 ++++++-- tuskar_ui/infrastructure/nodes/tables.py | 11 ++++++----- .../horizon/common/_data_table_table_actions.html | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tuskar_ui/api/node.py b/tuskar_ui/api/node.py index b61260636..984b9fdd8 100644 --- a/tuskar_ui/api/node.py +++ b/tuskar_ui/api/node.py @@ -652,8 +652,12 @@ class Node(base.APIResourceWrapper): @cached_property def ip_address(self): - return (self.instance._apiresource.addresses['ctlplane'][0] - ['addr']) + try: + apiresource = self.instace._apiresource + except AttributeError: + LOG.error("Couldn't obtain IP address") + return None + return apiresource.addresses['ctlplane'][0]['addr'] @cached_property def image_name(self): diff --git a/tuskar_ui/infrastructure/nodes/tables.py b/tuskar_ui/infrastructure/nodes/tables.py index 3452504e8..4ff80bc8c 100644 --- a/tuskar_ui/infrastructure/nodes/tables.py +++ b/tuskar_ui/infrastructure/nodes/tables.py @@ -111,11 +111,12 @@ class NodeFilterAction(tables.FilterAction): q = filter_string.lower() def comp(node): - return any(q in attr for attr in - (node.ip_address, - node.cpus, - node.memory_mb, - node.local_gb,)) + return any(q in unicode(value).lower() for value in ( + node.ip_address, + node.cpus, + node.memory_mb, + node.local_gb, + )) return filter(comp, nodes) diff --git a/tuskar_ui/infrastructure/templates/horizon/common/_data_table_table_actions.html b/tuskar_ui/infrastructure/templates/horizon/common/_data_table_table_actions.html index 2872a2158..4cc4afe3b 100644 --- a/tuskar_ui/infrastructure/templates/horizon/common/_data_table_table_actions.html +++ b/tuskar_ui/infrastructure/templates/horizon/common/_data_table_table_actions.html @@ -13,7 +13,7 @@