diff --git a/docs/source/api_reference/api_team.rst b/docs/source/api_reference/api_team.rst index 5f897ba8e..1d9cda508 100644 --- a/docs/source/api_reference/api_team.rst +++ b/docs/source/api_reference/api_team.rst @@ -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 diff --git a/src/superannotate/__init__.py b/src/superannotate/__init__.py index 191158e2f..c6a8a015d 100644 --- a/src/superannotate/__init__.py +++ b/src/superannotate/__init__.py @@ -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]) diff --git a/src/superannotate/lib/app/interface/sdk_interface.py b/src/superannotate/lib/app/interface/sdk_interface.py index 8e6fb04a8..2dfe694b6 100644 --- a/src/superannotate/lib/app/interface/sdk_interface.py +++ b/src/superannotate/lib/app/interface/sdk_interface.py @@ -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.") @@ -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.") diff --git a/src/superannotate/lib/infrastructure/utils.py b/src/superannotate/lib/infrastructure/utils.py index 638c9f9da..eaa75e80d 100644 --- a/src/superannotate/lib/infrastructure/utils.py +++ b/src/superannotate/lib/infrastructure/utils.py @@ -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)