File tree Expand file tree Collapse file tree 5 files changed +33
-23
lines changed
Expand file tree Collapse file tree 5 files changed +33
-23
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ _________________
110110
111111.. autofunction :: superannotate.get_team_metadata
112112.. autofunction :: superannotate.invite_contributor_to_team
113+ .. autofunction :: superannotate.delete_contributor_to_team_invitation
113114
114115----------
115116
Original file line number Diff line number Diff line change 6161 upload_preannotations_from_folder_to_project , upload_video_to_project ,
6262 upload_videos_from_folder_to_project
6363)
64- from .db .teams import get_team_metadata , invite_contributor_to_team
64+ from .db .teams import (
65+ delete_contributor_to_team_invitation , get_team_metadata ,
66+ invite_contributor_to_team
67+ )
6568from .db .users import search_team_contributors
6669from .dicom_converter import dicom_to_rgb_sequence
6770from .exceptions import (
Original file line number Diff line number Diff line change @@ -52,18 +52,25 @@ def get_team_metadata(convert_users_role_to_string=False):
5252 return res
5353
5454
55- # def delete_team_contributor_invitation(invitation):
56- # """Deletes team contributor invitation
57-
58- # :param invite: invitation metadata returned from invite_contributor_to_team
59- # :type project: dict
60- # """
61- # data = {'token': invitation["token"], 'e_mail': invitation['email']}
62- # response = _api.send_request(
63- # req_type='DELETE', path=f'/team/{_api.team_id}/invite', json_req=data
64- # )
65- # if not response.ok:
66- # raise SABaseException(
67- # response.status_code,
68- # "Couldn't delete contributor invite. " + response.text
69- # )
55+ def delete_contributor_to_team_invitation (email ):
56+ """Deletes team contributor invitation
57+
58+ :param email: invitation email
59+ :type email: str
60+ """
61+ team_metadata = get_team_metadata ()
62+ for invite in team_metadata ["pending_invitations" ]:
63+ if invite ["email" ] == email :
64+ break
65+ else :
66+ raise SABaseException (0 , "Couldn't find user " + email + " invitation" )
67+
68+ data = {'token' : invite ["token" ], 'e_mail' : invite ['email' ]} # pylint: disable=undefined-loop-variable
69+ response = _api .send_request (
70+ req_type = 'DELETE' , path = f'/team/{ _api .team_id } /invite' , json_req = data
71+ )
72+ if not response .ok :
73+ raise SABaseException (
74+ response .status_code ,
75+ "Couldn't delete contributor invite. " + response .text
76+ )
Original file line number Diff line number Diff line change 1- __version__ = "2.3.5 "
1+ __version__ = "2.3.6 "
Original file line number Diff line number Diff line change 22
33import superannotate as sa
44
5+ TEST_EMAIL = "hovnata1@superannotate.com"
6+
57
68def test_team_invite ():
7- try :
8- sa .invite_contributor_to_team ("hovnatan@superannotate.com" )
9- except sa .SABaseException as e :
10- assert e .message == 'Couldn\' t invite to team. {"error":"User with hovnatan@superannotate.com email is already member of this team."}'
11- else :
12- assert False
9+ sa .invite_contributor_to_team (TEST_EMAIL )
10+ sa .delete_contributor_to_team_invitation (TEST_EMAIL )
11+
1312 # sa.delete_team_contributor_invitation(invite)
1413
1514 # print(sa.search_team_contributors())
You can’t perform that action at this time.
0 commit comments