Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/api_reference/api_team.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ Team
.. automethod:: superannotate.SAClient.get_user_metadata
.. automethod:: superannotate.SAClient.set_user_custom_field
.. automethod:: superannotate.SAClient.list_users
.. automethod:: superannotate.SAClient.pause_user_activity
.. automethod:: superannotate.SAClient.resume_user_activity
2 changes: 1 addition & 1 deletion src/superannotate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys


__version__ = "4.4.31dev1"
__version__ = "4.4.31dev2"

os.environ.update({"sa_version": __version__})
sys.path.append(os.path.split(os.path.realpath(__file__))[0])
Expand Down
20 changes: 20 additions & 0 deletions src/superannotate/lib/app/interface/sdk_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,16 @@ def list_users(self, *, include: List[Literal["custom_fields"]] = None, **filter
def pause_user_activity(
self, pk: Union[int, str], projects: Union[List[int], List[str], Literal["*"]]
):
"""
Block the team contributor from requesting items from the projects.

:param pk: The email address or user ID of the team contributor.
:type pk: str or int

:param projects: A list of project names or IDs from which the user should be blocked.
The special value "*" means block access to all projects
:type projects: Union[List[int], List[str], Literal["*"]]
"""
user = self.controller.work_management.get_user_metadata(pk=pk)
if user.role is not WMUserTypeEnum.Contributor:
raise AppException("User must have a contributor role to pause activity.")
Expand All @@ -474,6 +484,16 @@ def pause_user_activity(
def resume_user_activity(
self, pk: Union[int, str], projects: Union[List[int], List[str], Literal["*"]]
):
"""
Resume the team contributor from requesting items from the projects.

:param pk: The email address or user ID of the team contributor.
:type pk: str or int

:param projects: A list of project names or IDs from which the user should be resumed.
The special value "*" means resume access to all projects
:type projects: Union[List[int], List[str], Literal["*"]]
"""
user = self.controller.work_management.get_user_metadata(pk=pk)
if user.role is not WMUserTypeEnum.Contributor:
raise AppException("User must have a contributor role to resume activity.")
Expand Down
6 changes: 4 additions & 2 deletions src/superannotate/lib/infrastructure/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,12 @@ def sync(self, project: ProjectEntity):
roles = response.data["data"]
self._K_V_map[project.id] = {
"role_name_id_map": {
role["role"]["name"]: role["role_id"] for role in roles
**{role["role"]["name"]: role["role_id"] for role in roles},
"ProjectAdmin": 3,
},
"role_id_name_map": {
role["role_id"]: role["role"]["name"] for role in roles
**{role["role_id"]: role["role"]["name"] for role in roles},
3: "ProjectAdmin",
},
}
self._update_cache_timestamp(project.id)
Expand Down