Skip to content

Commit 62d60bf

Browse files
authored
Project owner is optional (None if you have no read access rights) (#972)
* Project owner is optional (None if you have no read access rights) * changelog
1 parent b5484ff commit 62d60bf

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

webknossos/Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
2020

2121
### Fixed
2222

23+
- Fixed a bug in reading project info from webknossos using the api client for non-admins. [#972](https://github.com/scalableminds/webknossos-libs/pull/972)
24+
2325

2426
## [0.14.12](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.14.12) - 2023-12-19
2527
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.14.11...v0.14.12)

webknossos/webknossos/administration/project.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Project:
1919
name: str
2020
team_id: str
2121
team_name: str
22-
owner_id: str
22+
owner_id: Optional[str] # None in case you have no read access on the owner
2323
priority: int
2424
paused: bool
2525
expected_time: Optional[int]
@@ -75,16 +75,22 @@ def get_tasks(self, fetch_all: bool = False) -> List["Task"]:
7575

7676
def get_owner(self) -> User:
7777
"""Returns the user that is the owner of this task"""
78+
assert (
79+
self.owner_id is not None
80+
), "Project owner is None, you may not have enough access rights to read the project owner."
7881
return User.get_by_id(self.owner_id)
7982

8083
@classmethod
8184
def _from_api_project(cls, api_project: ApiProject) -> "Project":
85+
owner_id = None
86+
if api_project.owner is not None:
87+
owner_id = api_project.owner.id
8288
return cls(
8389
api_project.id,
8490
api_project.name,
8591
api_project.team,
8692
api_project.team_name,
87-
api_project.owner.id,
93+
owner_id,
8894
api_project.priority,
8995
api_project.paused,
9096
api_project.expected_time,

webknossos/webknossos/client/api_client/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class ApiProject:
235235
name: str
236236
team: str
237237
team_name: str
238-
owner: ApiUserCompact
238+
owner: Optional[ApiUserCompact] # None in case you have no read access on the owner
239239
priority: int
240240
paused: bool
241241
expected_time: Optional[int] = None

0 commit comments

Comments
 (0)