Skip to content

Commit 73a4d5e

Browse files
committed
allow attribs fetch for lists by default
1 parent 8a4d73c commit 73a4d5e

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

ayon_api/_api_helpers/lists.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,18 @@ def get_entity_lists(
5050
"""
5151
if fields is None:
5252
fields = self.get_default_fields_for_type("entityList")
53-
fields = set(fields)
53+
54+
# List does not have 'attrib' field but has 'allAttrib' field
55+
# which is json string and contains only values that are set
56+
o_fields = tuple(fields)
57+
fields = set()
58+
requires_attrib = False
59+
for field in o_fields:
60+
if field == "attrib" or field.startswith("attrib."):
61+
requires_attrib = True
62+
field = "allAttrib"
63+
fields.add(field)
64+
5465
if "items" in fields:
5566
fields.discard("items")
5667
fields |= {
@@ -60,6 +71,10 @@ def get_entity_lists(
6071
"items.position",
6172
}
6273

74+
available_attribs = []
75+
if requires_attrib:
76+
available_attribs = self.get_attributes_for_type("list")
77+
6378
if active is not None:
6479
fields.add("active")
6580

@@ -82,6 +97,15 @@ def get_entity_lists(
8297
if isinstance(attributes, str):
8398
entity_list["attributes"] = json.loads(attributes)
8499

100+
if requires_attrib:
101+
all_attrib = json.loads(
102+
entity_list.get("allAttrib") or "{}"
103+
)
104+
entity_list["attrib"] = {
105+
attrib_name: all_attrib.get(attrib_name)
106+
for attrib_name in available_attribs
107+
}
108+
85109
self._convert_entity_data(entity_list)
86110

87111
yield entity_list

ayon_api/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@
247247
DEFAULT_ENTITY_LIST_FIELDS = {
248248
"id",
249249
"count",
250+
"allAttrib",
250251
"attributes",
251252
"active",
252253
"createdBy",

0 commit comments

Comments
 (0)