Skip to content

Commit 5a25b66

Browse files
authored
Merge branch 'develop' into enhancement/events-graphql-update
2 parents cfd51f0 + df7159f commit 5a25b66

3 files changed

Lines changed: 33 additions & 13 deletions

File tree

ayon_api/_api.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,6 @@ def upload_reviewable(
12761276
content_type: Optional[str] = None,
12771277
filename: Optional[str] = None,
12781278
progress: Optional[TransferProgress] = None,
1279-
headers: Optional[dict[str, Any]] = None,
12801279
**kwargs,
12811280
) -> requests.Response:
12821281
"""Upload reviewable file to server.
@@ -1291,7 +1290,6 @@ def upload_reviewable(
12911290
filename (Optional[str]): User as original filename. Filename from
12921291
'filepath' is used when not filled.
12931292
progress (Optional[TransferProgress]): Progress.
1294-
headers (Optional[dict[str, Any]]): Headers.
12951293
12961294
Returns:
12971295
requests.Response: Server response.
@@ -1306,7 +1304,6 @@ def upload_reviewable(
13061304
content_type=content_type,
13071305
filename=filename,
13081306
progress=progress,
1309-
headers=headers,
13101307
**kwargs,
13111308
)
13121309

ayon_api/_api_helpers/projects.py

Lines changed: 19 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
@@ -810,8 +811,24 @@ def _get_graphql_projects(
810811
for project in parsed_data["projects"]:
811812
if active is not None and active is not project["active"]:
812813
continue
813-
if own_attributes:
814-
fill_own_attribs(project)
814+
815+
if library is not None and library is not project["library"]:
816+
continue
817+
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+
815832
self._fill_project_entity_data(project)
816833
yield project
817834

ayon_api/server_api.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,10 @@ def _download_file_to_stream(
14081408
try:
14091409
with get_func(url, **kwargs) as response:
14101410
# Auto-fix missing 'api/'
1411-
if response.status_code == 405 and not api_prepended:
1411+
if (
1412+
response.status_code in (404, 405)
1413+
and not api_prepended
1414+
):
14121415
api_prepended = True
14131416
if (
14141417
not endpoint.startswith(self._base_url)
@@ -1792,7 +1795,10 @@ def _upload_file(
17921795
url = self._endpoint_to_url(endpoint, use_rest=False)
17931796
progress.set_destination_url(url)
17941797

1795-
headers = kwargs.setdefault("headers", {})
1798+
headers = kwargs.get("headers")
1799+
if headers is None:
1800+
kwargs["headers"] = headers = {}
1801+
17961802
headers_keys_by_low_key = {key.lower(): key for key in headers}
17971803
if self._session is None:
17981804
for key, value in self.get_headers().items():
@@ -1838,7 +1844,7 @@ def _upload_file(
18381844
**kwargs
18391845
)
18401846
# Auto-fix missing 'api/'
1841-
if response.status_code == 405 and not api_prepended:
1847+
if response.status_code in (404, 405) and not api_prepended:
18421848
api_prepended = True
18431849
if (
18441850
not endpoint.startswith(self._base_url)
@@ -1982,7 +1988,6 @@ def upload_reviewable(
19821988
content_type: Optional[str] = None,
19831989
filename: Optional[str] = None,
19841990
progress: Optional[TransferProgress] = None,
1985-
headers: Optional[dict[str, Any]] = None,
19861991
**kwargs
19871992
) -> requests.Response:
19881993
"""Upload reviewable file to server.
@@ -1997,7 +2002,6 @@ def upload_reviewable(
19972002
filename (Optional[str]): User as original filename. Filename from
19982003
'filepath' is used when not filled.
19992004
progress (Optional[TransferProgress]): Progress.
2000-
headers (Optional[dict[str, Any]]): Headers.
20012005
20022006
Returns:
20032007
requests.Response: Server response.
@@ -2026,7 +2030,6 @@ def upload_reviewable(
20262030
progress=progress,
20272031
content_type=content_type,
20282032
filename=filename,
2029-
headers=headers,
20302033
request_type=RequestTypes.post,
20312034
**kwargs
20322035
)
@@ -2425,8 +2428,11 @@ def _prepare_fields(
24252428
fields.remove("attrib")
24262429
fields |= self.get_attributes_fields_for_type(entity_type)
24272430

2428-
if own_attributes and entity_type in {"project", "folder", "task"}:
2429-
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")
24302436

24312437
if entity_type != "project":
24322438
return

0 commit comments

Comments
 (0)