Просмотр исходного кода

Fixes incorrectly handled type error when list of objects is found in data (#12593)

* fixes incorrectly handled type error when list of objects is found in data #9876

* fixes incorrectly handled type error when list of objects is found in data #9876

* fixes incorrectly handled type error when list of objects is found in data #9876
Abhimanyu Saharan 2 лет назад
Родитель
Сommit
e7f689bc52
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      netbox/extras/conditions.py

+ 7 - 1
netbox/extras/conditions.py

@@ -65,8 +65,14 @@ class Condition:
         """
         """
         Evaluate the provided data to determine whether it matches the condition.
         Evaluate the provided data to determine whether it matches the condition.
         """
         """
+        def _get(obj, key):
+            if isinstance(obj, list):
+                return [dict.get(i, key) for i in obj]
+
+            return dict.get(obj, key)
+
         try:
         try:
-            value = functools.reduce(dict.get, self.attr.split('.'), data)
+            value = functools.reduce(_get, self.attr.split('.'), data)
         except TypeError:
         except TypeError:
             # Invalid key path
             # Invalid key path
             value = None
             value = None