Skip to content

Commit df7159f

Browse files
authored
Merge pull request #320 from ynput/bugfix/projects-own-attribs
Projects: Own attrib with GraphQl
2 parents 6626fa6 + a523736 commit df7159f

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

ayon_api/_api_helpers/projects.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import copy
34
import json
45
import platform
56
import warnings
@@ -814,8 +815,20 @@ def _get_graphql_projects(
814815
if library is not None and library is not project["library"]:
815816
continue
816817

817-
if own_attributes:
818-
fill_own_attribs(project)
818+
all_attrib = project.get("allAttrib")
819+
if isinstance(all_attrib, str):
820+
all_attrib = json.loads(all_attrib)
821+
project["allAttrib"] = all_attrib
822+
823+
if own_attributes and all_attrib:
824+
own_attrib = {}
825+
if all_attrib:
826+
own_attrib = copy.deepcopy(all_attrib)
827+
attrib = project.get("attrib", {})
828+
for key in attrib.keys():
829+
own_attrib.setdefault(key, None)
830+
project["ownAttrib"] = own_attrib
831+
819832
self._fill_project_entity_data(project)
820833
yield project
821834

ayon_api/server_api.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2428,8 +2428,11 @@ def _prepare_fields(
24282428
fields.remove("attrib")
24292429
fields |= self.get_attributes_fields_for_type(entity_type)
24302430

2431-
if own_attributes and entity_type in {"project", "folder", "task"}:
2432-
fields.add("ownAttrib")
2431+
if own_attributes:
2432+
if entity_type == "project":
2433+
fields.add("allAttrib")
2434+
elif entity_type in {"folder", "task"}:
2435+
fields.add("ownAttrib")
24332436

24342437
if entity_type != "project":
24352438
return

0 commit comments

Comments
 (0)