Skip to content

Commit c17db70

Browse files
author
Vaghinak Basentsyan
committed
Changed function interface
1 parent d4df27b commit c17db70

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/superannotate/lib/core/usecases/projects.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,8 @@ def execute(self):
981981
if user["user_role"] > constances.UserRole.ADMIN.value:
982982
project_users.add(user["email"])
983983

984-
to_add = team_users.intersection(self._emails) - project_users
985-
to_skip = set(self._emails).difference(to_add)
984+
to_add = list(team_users.intersection(self._emails) - project_users)
985+
to_skip = list(set(self._emails).difference(to_add))
986986

987987
if to_skip:
988988
self.reporter.log_warning(
@@ -1001,7 +1001,7 @@ def execute(self):
10011001
if response and not response.get("invalidUsers"):
10021002
self.reporter.log_info(
10031003
f"Added {len(to_add)}/{len(self._emails)} "
1004-
"contributors to the project <project_name> with the <role> role."
1004+
f"contributors to the project {self._project.name} with the {self.user_role} role."
10051005
)
10061006
self._response.data = to_add, to_skip
10071007
return self._response
@@ -1027,18 +1027,13 @@ def __init__(
10271027
self._service = service
10281028

10291029
def execute(self):
1030-
team_users = set()
1031-
for user in self._team.users:
1032-
if user.user_role > constances.UserRole.ADMIN.value:
1033-
team_users.add(user.email)
1034-
# collecting pending team users which is not admin
1035-
for user in self._team.pending_invitations:
1036-
if user["user_role"] > constances.UserRole.ADMIN.value:
1037-
team_users.add(user["email"])
1030+
team_users = {user.email for user in self._team.users}
1031+
# collecting pending team users
1032+
team_users.update({user.email for user in self._team.pending_invitations})
10381033

10391034
emails = set(self._emails)
10401035

1041-
to_skip = emails.intersection(team_users)
1036+
to_skip = list(emails.intersection(team_users))
10421037
to_add = list(emails.difference(to_skip))
10431038

10441039
if to_skip:
@@ -1054,7 +1049,8 @@ def execute(self):
10541049
)
10551050
if response:
10561051
self.reporter.log_info(
1057-
f"Sent team <admin/contributor> invitations to {len(to_add)}/{len(self._emails)}."
1052+
f"Sent team {'admin' if self._set_admin else 'contributor'} invitations"
1053+
f" to {len(to_add)}/{len(self._emails)} users."
10581054
)
10591055
self._response.data = to_add, to_skip
10601056
return self._response

0 commit comments

Comments
 (0)