Skip to content

Commit

Permalink
Project owner is optional (None if you have no read access rights) (#972
Browse files Browse the repository at this point in the history
)

* Project owner is optional (None if you have no read access rights)

* changelog
  • Loading branch information
fm3 authored Jan 2, 2024
1 parent b5484ff commit 62d60bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions webknossos/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ For upgrade instructions, please check the respective _Breaking Changes_ section

### Fixed

- 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)


## [0.14.12](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.14.12) - 2023-12-19
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.14.11...v0.14.12)
Expand Down
10 changes: 8 additions & 2 deletions webknossos/webknossos/administration/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Project:
name: str
team_id: str
team_name: str
owner_id: str
owner_id: Optional[str] # None in case you have no read access on the owner
priority: int
paused: bool
expected_time: Optional[int]
Expand Down Expand Up @@ -75,16 +75,22 @@ def get_tasks(self, fetch_all: bool = False) -> List["Task"]:

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

@classmethod
def _from_api_project(cls, api_project: ApiProject) -> "Project":
owner_id = None
if api_project.owner is not None:
owner_id = api_project.owner.id
return cls(
api_project.id,
api_project.name,
api_project.team,
api_project.team_name,
api_project.owner.id,
owner_id,
api_project.priority,
api_project.paused,
api_project.expected_time,
Expand Down
2 changes: 1 addition & 1 deletion webknossos/webknossos/client/api_client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class ApiProject:
name: str
team: str
team_name: str
owner: ApiUserCompact
owner: Optional[ApiUserCompact] # None in case you have no read access on the owner
priority: int
paused: bool
expected_time: Optional[int] = None
Expand Down

0 comments on commit 62d60bf

Please sign in to comment.