Skip to content

Commit f51075f

Browse files
committed
use allAttrib instead of attrib
1 parent fd47038 commit f51075f

2 files changed

Lines changed: 27 additions & 15 deletions

File tree

ayon_api/_api_helpers/projects.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -816,15 +816,15 @@ def _get_graphql_projects(
816816
if library is not None and library is not project["library"]:
817817
continue
818818

819+
attrib = None
819820
all_attrib = project.get("allAttrib")
820821
if isinstance(all_attrib, str):
821-
all_attrib = json.loads(all_attrib)
822-
project["allAttrib"] = all_attrib
822+
attrib = json.loads(all_attrib)
823823

824-
if all_attrib is not None:
825-
project["ownAttrib"] = list(all_attrib)
826-
827-
attrib = copy.deepcopy(all_attrib)
824+
if attrib is not None:
825+
# NOTE 'ownAttrib' logic might change in the future if
826+
# allAttrib would return all attribute values.
827+
project["ownAttrib"] = list(attrib)
828828
project["attrib"] = attrib
829829
for name, attr_data in (
830830
self.get_attributes_for_type("project").items()

ayon_api/server_api.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,16 +2424,21 @@ def _prepare_fields(
24242424
if not fields:
24252425
return
24262426

2427-
if "attrib" in fields:
2428-
fields.remove("attrib")
2429-
fields |= self.get_attributes_fields_for_type(entity_type)
2427+
add_all_attrib = False
2428+
for field in tuple(fields):
2429+
if field == "attrib" or field.startswith("attrib."):
2430+
fields.discard(field)
2431+
add_all_attrib = True
24302432

24312433
if own_attributes:
24322434
if entity_type == "project":
2433-
fields.add("allAttrib")
2435+
add_all_attrib = True
24342436
elif entity_type in {"folder", "task"}:
24352437
fields.add("ownAttrib")
24362438

2439+
if add_all_attrib:
2440+
fields.add("allAttrib")
2441+
24372442
if entity_type != "project":
24382443
return
24392444

@@ -2499,11 +2504,18 @@ def _prepare_advanced_filters(
24992504
return filters
25002505

25012506
def _convert_entity_data(self, entity: AnyEntityDict):
2502-
if not entity or "data" not in entity:
2507+
if not entity:
25032508
return
25042509

2505-
entity_data = entity["data"] or {}
2506-
if isinstance(entity_data, str):
2507-
entity_data = json.loads(entity_data)
2510+
if "data" in entity:
2511+
entity_data = entity["data"] or {}
2512+
if isinstance(entity_data, str):
2513+
entity_data = json.loads(entity_data)
2514+
2515+
entity["data"] = entity_data
25082516

2509-
entity["data"] = entity_data
2517+
all_attrib = entity.get("allAttrib")
2518+
if isinstance(all_attrib, str):
2519+
# NOTE: This expects server returns all attributes available for
2520+
# the entity type.
2521+
entity["attrib"] = json.loads(all_attrib)

0 commit comments

Comments
 (0)